我确信这个问题已经回答,但我找不到。 如何在谷歌地图v3 Javascript api上更改标记的标记图层?
例如,在下图中,我希望总线图标显示在所有T
图标上方。
我的公交车图标是这样的:
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
存储在本地,因为总线是实时数据并按需提供。
答案 0 :(得分: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 // <--
});
答案 1 :(得分:1)
您可以根据标记的需要设置function [ hFig ] = init_background_grid(thickness)
%% Background
hFig=figure;
backax = axes('Parent', hFig);
% Ensure that this is below other objects
uistack(backax, 'bottom');
% Span the whole figure
set(backax, 'Position', [0 0 1 1]);
grid(backax, 'on')
% Make it invisible except for the grid and
% ensure it isn't able to be interacted with
set(backax, 'HitTest', 'off', ...
'HandleVisibility', 'off', ...
'GridLineStyle', '-', ...
'Color', 'none', ...
'XColor', 'none', ...
'YColor', 'none')
% Determine grid spacing with x/y ticks
% Increase nLines for a finer grid
nLines = thickness; % 30 default
set(backax, 'XTick', linspace(0, 1, nLines), ...
'YTick', linspace(0, 1, nLines));
end
像:
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()