out*_*man 10 google-maps-api-3 google-maps-markers
有人可以帮助我把当前位置放在所有其他位置前吗?我已经阅读了有关MAX_ZINDEX和setZindex()但我无法理解的内容.这是我的代码:
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);
Run Code Online (Sandbox Code Playgroud)
And*_*ach 12
MAX_ZINDEX
是常量,而不是标记的属性.
相关的MarkerOption是zIndex
:
var marker = new google.maps.Marker({
map: map,
position: latlng,
title:'pk:'+name,
zIndex: zInd,
icon: image
});
Run Code Online (Sandbox Code Playgroud)
这zIndex
会将标记的属性设置为您计算的值,这比API的最大值多一个.