[英]Two markers on google map for one place
I have simple google map with markers. 我有简单的谷歌地图标记。 When I create marker for example for Viet Nam I see two markers on Map (in the beginning and in the end, see screenshot).
当我为越南创建标记时,我在地图上看到两个标记(在开头和结尾,见截图)。
Is there any way to show only one marker? 有没有办法只显示一个标记? I cannot change size or zoom of map.
我无法改变地图的大小或缩放。
Code: 码:
function loadMap() {
var mapOptions = {
zoom: 1,
disableDefaultUI: true,
zoomControl: false,
scrollwheel: false,
center: new google.maps.LatLng(10.0, -97.2070),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
MAP = new google.maps.Map(document.getElementById("map"), mapOptions);
}
function addMarker(address) {
geocoder = new google.maps.Geocoder();
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var marker = new google.maps.Marker({
map: MAP,
position: results[0].geometry.location
});
MARKERS.push(marker);
}});
}
The short answer is: No
, You basically see the same icon, in the same location. 简短的回答是:
No
,你基本上在同一个位置看到相同的图标。 because you zoomed out the map that way that you see the same land twice. 因为你缩小了地图的方式,你看到同一块土地两次。 it's a normal behavior.
这是正常的行为。 there is no logic that in one round there will be a marker and in the second there wouldn't.
没有逻辑,在一轮中会有一个标记,而在第二轮则没有。
You can set the minimum zoom to a larger number so you won't be able to zoom out that far. 您可以将最小缩放设置为较大的数字,这样您就无法缩小那么远。 But that comes with some issues, your map will have to have a fixed width.
但是这有一些问题,你的地图必须有一个固定的宽度。
Look at minZoom
https://developers.google.com/maps/documentation/javascript/reference#MapOptions 查看
minZoom
https://developers.google.com/maps/documentation/javascript/reference#MapOptions
Otherwise I don't see how you can do that. 否则我不知道你怎么能这样做。
My problem is solved, I needed to add option "optimized: false" for markers. 我的问题解决了,我需要为标记添加选项“optimized:false”。 After this I have one marker for one place.
在此之后,我有一个地方的标记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.