This example shows you how easily jQuery + jMaps makes using marker managers.
In example 1, we'll look at using the default GMarkerManager which comes with google maps.
In the second example, we use the Open source Marker Manager available from the GMaps Utility Library
In both cases, the API is exactly the same, however the open source marker manager has some improvements over the Google one. You do not need to handle AddMarker in any special way with a marker manager, AddMarker will detect it and automatically add it.
jQuery(document).ready(function(){
jQuery('#map1, #map2').jmap('init', {'mapType':G_HYBRID_MAP,'mapCenter':[37.4419, -122.1419], 'mapZoom':5});
jQuery('#map1').jmap('CreateMarkerManager');
for (var i=0;i<10;i++) {
var lat = 37.44 + (Math.random() - 0.5)*14.5;
var lng = -122.14 + (Math.random() - 0.5)*36.0;
jQuery('#map1').jmap('AddMarker', {'pointLatLng': [lat,lng]});
}
});
jQuery(document).ready(function(){
jQuery('#map2').jmap('CreateMarkerManager', {'markerManager':'MarkerManager'});
for (var i=0;i<10;i++) {
var lat = 37.44 + (Math.random() - 0.5)*14.5;
var lng = -122.14 + (Math.random() - 0.5)*36.0;
jQuery('#map2').jmap('AddMarker', {'pointLatLng': [lat,lng]});
}
});