Google maps api 3 将Google Maps v3中的标记放在所有其他标记前面

Google maps api 3 将Google Maps v3中的标记放在所有其他标记前面,google-maps-api-3,google-maps-markers,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 {

有人能帮我把现在的位置摆在所有人面前吗?我读过关于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);

大多数代码都有意义,但是
MarkerOptions
对象的定义没有意义。尝试将标记创建代码更改为:

var marker = new google.maps.Marker({
    map: map,
    position: latlng,
    title:'pk:'+name,
    zIndex: zInd,
    icon: image
});

由于您已将
zInd
的值设置为高于
google.maps.Marker.MAX\u ZINDEX
,因此进行此更改应将标记置于ZINDEX的更高位置,从而高于地图上的其他标记。

MAX\u ZINDEX
是一个常量,而不是标记的属性

相关的标记选项是
zIndex

var marker = new google.maps.Marker({
    map: map,
    position: latlng,
    title:'pk:'+name,
    zIndex: zInd,
    icon: image
});

这会将标记的
zIndex
属性设置为您计算的值,该值比API的最大值高一个。

我已经尝试过了,'zIndex:999,',它根本不工作,这会给我一个错误位置,但如果我使用'google.maps.event.addListener(标记,'mouseover',function(){marker.setZIndex(9999);ib.close();//ib.setContent($infoWindowContent[0]);ib.open(映射,标记)59440问题找到了。我回复了你在问题中提交的代码,但你在我的回答中说你已经尝试过了。如果你想用你当前的代码和你尝试过的内容更新你的问题,我将尝试帮助你。否则,我将不得不承认我无法理解你在说什么也许你可以提供一个链接到你的页面或者设置一个JSFIDLE?