Hi all,
In google maps when i set a center through
map.setCenter(new GLatLng(28.6589, 77.2104), 13);
it not only sets the centre of the map but adds a marker on that place which i dont want it to be
can anyone help me out?
with thanks Ankur
Ok guys I feel no harm to share my code at least it may help others also Here's the entire script I wrote
<script type="text/javascript">
var map;
function initialize() {
if (GBrowserIsCompatible()) {
map= new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(28.6589, 77.2104), 13);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.clearOverlays();
//alert(PlottingMarkersDetails);
}
setInterval("plotVehicles()",1000);
}
function plotVehicles()
{
try
{
map.clearOverlays();
var bounds = new GLatLngBounds();
if(document.getElementById("<%=hf_SelectedVehiclePlottingDetails.ClientID %>"))
{
var PlottingMarkersDetails=document.getElementById("<%=hf_SelectedVehiclePlottingDetails.ClientID %>").value;
var arrVehicleDetails=PlottingMarkersDetails.split("@");
alert(arrVehicleDetails.length);
for(var i=0; i<arrVehicleDetails.length;i++)
{
var currentVehicleInfo=arrVehicleDetails[i].split(",");
var point = new GLatLng(parseFloat(currentVehicleInfo[1]),parseFloat(currentVehicleInfo[2]));
var marker = createMarker(point,currentVehicleInfo[0] + "<br/>" + currentVehicleInfo[4] + "<br/>" + currentVehicleInfo[3] );
//bounds.extend(point);
map.addOverlay(marker);
}
//map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
}
}
catch(err)
{
}
}
function createMarker(point,html) {
var blueIcon = new GIcon(G_DEFAULT_ICON);
blueIcon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png";
markerOptions = { icon:blueIcon };
var marker = new GMarker(point,markerOptions);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(html);
});
return marker;
}
</script>