将标记从谷歌地图v3放在所有其他人面前 [英] Put marker from Google Maps v3 in front of all others

查看:88
本文介绍了将标记从谷歌地图v3放在所有其他人面前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我把当前位置放在所有其他位置?我已经阅读了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);


解决方案

MAX_ZINDEX

相关的MarkerOption是 zIndex

p>

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

这会将标记的 zIndex 属性设置为你已经计算出的价值,比API的最大值多一个。


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_ZINDEXis a constant, not an attribute of a marker.

The relevant MarkerOption is zIndex:

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

This sets the marker's zIndex attribute to the value you have calculated, which is one more than the API's maximum value.

这篇关于将标记从谷歌地图v3放在所有其他人面前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆