Can somebody help me put the current location in front of all others? I have read about MAX_ZINDEX and setZindex() but I cannot understand it. This is my code:
var latlng = new google.maps.LatLng(lat,lng);
var image = "";
var currentplace = "Ohla Hotel";
var zInd = "";
if( name == currentplace ) {
image = "../img/hotel_icon.png";
}
else {
image = "../img/home_icon.png";
}
//alert();
var maxZindex = google.maps.Marker.MAX_ZINDEX;
if( name == currentplace ) {
zInd = (maxZindex + 1);
}
var locationDescription = this.locationDescription;
var marker = new google.maps.Marker({
map: map,
position: latlng,
title:'pk:'+name,
MAX_ZINDEX: zInd,
icon: image
});
bounds.extend(latlng);
setMarker(map, marker, name, locationDescription);
MAX_ZINDEX
is a constant, not an attribute of a marker.The relevant MarkerOption is
zIndex
:This sets the marker's
zIndex
attribute to the value you have calculated, which is one more than the API's maximum value.Most of your code makes sense, but your definition of the
MarkerOptions
api-doc object doesn't make sense. Try changing your marker creation code to this:Since you have already set the value of
zInd
higher thangoogle.maps.Marker.MAX_ZINDEX
, making this change should place the marker higher in the zIndex and thus above the other markers on the map.