我通常使用谷歌地图并使用它将十字准线图标绑定到地图的中心
var image = {
url: 'images/site/crosshair.png',
size: new google.maps.Size(32, 32),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(16, 16)
};
var xhr = new google.maps.Marker({
map: map,
icon: image
});
xhr.bindTo('position', map, 'center');
如何使用leaflet.js复制此内容?我有这个设置中心的图标,但它不会随着地图被拖动或缩放而更新
//create crosshair icon
var crosshair = L.icon({
iconUrl: 'img/site/crosshair.png',
iconSize: [32, 32],
iconAnchor:[16,37]
});
L.marker(map.getCenter(), {icon: crosshair}).addTo(map);
希望你能帮忙