Google maps 如何更改标记下方的十字(Google Map V3)?
Google maps 如何更改标记下方的十字(Google Map V3)?,google-maps,google-maps-api-3,google-maps-markers,Google Maps,Google Maps Api 3,Google Maps Markers,如何更改标记下方的十字?没有基于API的选项来更改十字 有一种可能的CSS解决方法: img[src^='https://mts.googleapis.com/vt/icon/name=icons/spotlight/directions_drag_cross']{ /*your custom image, 16*16, used as background*/ background:url(http://i.imgur.com/FKMkIVQ.png); /*give th
如何更改标记下方的十字?没有基于API的选项来更改十字 有一种可能的CSS解决方法:
img[src^='https://mts.googleapis.com/vt/icon/name=icons/spotlight/directions_drag_cross']{
/*your custom image, 16*16, used as background*/
background:url(http://i.imgur.com/FKMkIVQ.png);
/*give the default-image a large width,
it will be cropped to 16*16, so the cross will disappear*/
width:200px !important;
height:200px !important;
}
问题是:十字架的图像src可能有一天会改变,那么选择器将不再匹配
演示:
更好的方法是禁用十字并观察dragstart和dragend,以便在拖动时应用不同的标记(使用自定义十字)。最简单的方法是使用set-raiseOnDrag:false for marker options
var marker = new google.maps.Marker({
position: latLng,
title: 'Point A',
map: map,
draggable: true,
raiseOnDrag: false
})) 你的代码看起来像什么?你的记号笔可以拖动吗?拖动时是否要删除十字
crossOnDrag boolean如果为false,则在拖动时禁用标记下方显示的交叉。默认情况下,此选项为true。
从@geocodezip中,我想在圆圈中替换他。谢谢,这正是我需要的。非常感谢。