Hi All,
I have a target of displaying atleast 30000-50000 markers on my map. I
currently am displaying just 2200 markers, but it is taking some time
to get downloaded. I am using the following code:
var customIcons = [];
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map"));
map.enableContinuousZoom();map.enableScrollWheelZoom();
var otherOpts = {buttonStartingStyle: {paddingTop: '4px', paddingLeft:
'4px'},buttonHTML: '<img title="Drag Zoom In" src="./
zoomin.png">',buttonStyle: {width:'25px',marginTop:'1px',
height:'23px'},buttonZoomingHTML: '',buttonZoomingStyle:
{width:'175px', height:'100%'},backButtonHTML: '<img title="Zoom Back
Out" src="./zoomout.png">', backButtonStyle:
{display:'none',marginTop:'5px',width:'25px',
height:'23px'},backButtonEnabled: true,overlayRemoveTime: 1500 }
map.addControl(new DragZoomControl({}, otherOpts, {}), new
GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7,15)));
map.addControl(new GMenuMapTypeControl());
map.addControl(new GSmallMapControl(), new GControlPosition
(G_ANCHOR_TOP_LEFT, new GSize(10,79)));map.addMapType(G_PHYSICAL_MAP);
map.setCenter(new GLatLng(37.09024,-95.7129),4,G_PHYSICAL_MAP);
GDownloadUrl("http://gtbeta.net/indexmarkers.xml", function(data)
{
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++)
{
var individualid = markers[i].getAttribute("individualid");
var name = markers[i].getAttribute("name");
var address = markers[i].getAttribute("address");
var rank = markers[i].getAttribute("rank");
var img = markers[i].getAttribute("img");
var coverpic = markers[i].getAttribute("coverpic");
var iconDynamic = new GIcon();
iconDynamic.image = img;
iconDynamic.iconSize = new GSize(30, 30);
iconDynamic.iconAnchor = new GPoint(6, 20);
iconDynamic.infoWindowAnchor = new GPoint(5, 1);
customIcons["Dynamic"] = iconDynamic;
var point = new GLatLng(parseFloat(markers[i].getAttribute
("lat")),parseFloat(markers[i].getAttribute("lng")));
var marker = GmapPlotter(point, individualid, name, address, img,
rank, coverpic);
map.addOverlay(marker);
}
}
);
}
function GmapPlotter(point, individualid, name, address, img, rank,
coverpic)
{
var str = name.replace(/ /g,"-");
var marker = new GMarker(point,customIcons["Dynamic"]);
var html = "<table width='200px' height='100%'><tr align='left'><td
align='center' height='100px'><img src='" + coverpic +"' width='130px'
height='100px'/></td></tr><tr align='left'><td>";
html = html + "<a href='http://gtbeta.net/" + individualid + "_" + str
+ ".html' class='black'><b>" + name + "</b></a> <br/>";
for(var r=1;r<=rank;r++)
{
html = html + "<img src='http://gtbeta.net/images/rating-active.gif'
alt='star' /> ";
}
for(var t=rank;t<5;t++)
{
html = html + "<img src='http://gtbeta.net/images/rating-inactive.gif'
alt='star' /> ";
}
html = html + "<br/></td></tr></table>";
GEvent.addListener(marker, 'click', function() {
marker.openInfoWindowHtml(html);
}
);
return marker;
}
test url:
http://gtbeta.net
My query is :
1. Is it possible to display that many (50000+) markers on the map
without compromising on the download time ?
2. If not possible, are there any other alternative out there ? It
will be gr8 on your part if you can send some sample code or
websites.
3. If these issues are not feasible, I also had set a plan to display
a particular amount of markers on a particular zoom level and then
when any user zooms in, the marker amount will increase.Also when any
user drags across the map, the markers will get automatically plotted
depending on the area dragged. I had tried this using GMarkerManager
but to no effect. It was painfully slow as GMarkerManager was first
putting all the markers in one array and then displaying those markers
according to the zoom level selected.I had seen a site called
tripwolf.com where in they are using this mechanism and it is very
fast.
Can you plz guide me thru this ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---