Only last marker shows up on map

Feb 18, 2011 at 5:11 PM

Hi, I loop through a dataview to add markers, but only the last marker shows up on the map.  Can anyone notice what I'm doing wrong??

GoogleMap

 

map = (GoogleMap)ctl.FindControl("VendorMap"

);

 

if (map != null

)

{

 

GoogleMarker marker = new GoogleMarker

();

 

//map.Markers.Clear();

 

DataView view = (DataView)AssignedVendorsDS.Select(DataSourceSelectArguments

.Empty);

 

foreach (DataRowView rv in

view)

{

 

//rv[0];

 

string address = rv["Address"] + ", " + rv["City"] + ", " + rv["StateAbbrev"] + " " + rv["Zip"

];

 

//marker.Address = address;

 

if (rv["Lattitude"] != System.DBNull.Value && rv["Longitude"] != System.DBNull

.Value)

{

marker.Latitude =

Convert.ToDouble(rv["Lattitude"

]);

marker.Longitude =

Convert.ToDouble(rv["Longitude"

]);

marker.Text = address;

map.Markers.Add(marker);

}

}

}

Feb 18, 2011 at 5:15 PM

Resolved, moved the line:

GoogleMarker marker = new GoogleMarker();

Into the loop:

GoogleMap

 

map = (GoogleMap)ctl.FindControl("VendorMap"

);

 

if (map != null

)

{

 

 

//map.Markers.Clear();

 

DataView view = (DataView)AssignedVendorsDS.Select(DataSourceSelectArguments

.Empty);

 

foreach (DataRowView rv in

view)

{

 

//rv[0];

 

string address = rv["Address"] + ", " + rv["City"] + ", " + rv["StateAbbrev"] + " " + rv["Zip"

];

 

//marker.Address = address;

 

if (rv["Lattitude"] != System.DBNull.Value && rv["Longitude"] != System.DBNull

.Value)

{

 

GoogleMarker marker = new GoogleMarker

();

marker.Latitude =

Convert.ToDouble(rv["Lattitude"

]);

marker.Longitude =

Convert.ToDouble(rv["Longitude"

]);

marker.Text = address;

map.Markers.Add(marker);

}

}

}

Feb 1, 2012 at 7:56 AM

Dear all,

I'm working in a project which get the coordinates of many points from DB to draw it in the map to help some engineers for planning

Is there any way to display 1000s markers or icon in the same map control with acceptable performance ?