2016-03-03 99 views
0

我相信这个问题已经回答了,但我不能找到它。 如何更改标记的标记层上谷歌地图V3的JavaScript API?如何控制标记是谷歌地图的JavaScript哪一层?

例如图像中的下面我想要的总线图标出现上述所有T图标。

enter image description here

我的公交车图标是由这样的:

var image = { 
    url: getIconUrl(bus.num), 
    anchor: new google.maps.Point(30,30) 
    }; 
    var marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(bus.Latitude, bus.Longitude), 
    map: $scope.map, 
    animation: google.maps.Animation.DROP, 
    icon: image 
    }); 

T图标是由这样的:

var image = { 
    url: stopIcon 
    }; 
    var marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(stop.Latitude, stop.Longitude), 
    map: $scope.map, 
    icon: image 
    }); 

这辆巴士后T因为T总是做本地存储的地方是公交车是实时数据并按需提供。

回答

1

你可以设置zIndex按需要为您的标记

,如:

var marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(stop.Latitude, stop.Longitude), 
    map: $scope.map, 
    icon: image, 
    zIndex: 1// as needed 
    }); 

,也可以使用setZIndex()方法改成:

var marker = new google.maps.Marker({ 
     position: new google.maps.LatLng(stop.Latitude, stop.Longitude), 
     map: $scope.map, 
     icon: image 
     }); 

marker.setZIndex(google.maps.Marker.MAX_ZINDEX + 1); 
1

您可以用z-index选项来控制。

var image = { 
    url: getIconUrl(bus.num), 
    anchor: new google.maps.Point(30,30) 
    }; 
    var marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(bus.Latitude, bus.Longitude), 
    map: $scope.map, 
    animation: google.maps.Animation.DROP, 
    icon: image, 
    zIndex: google.maps.Marker.MAX_ZINDEX // <-- 
    });