我想通過點擊谷歌地圖(設置中心)並在地圖上移動(以設置半徑)繪製圓。Gmaps鼠標移動到圓形,多邊形或矩形上
它可以讓我做出更大的圓,但是當我讓圓更小時,它就可以工作。
的問題是,鼠標移動時,不要穿過圓圈,當鼠標懸停在圓圈標示不火任何mousemouse ...
這裏是小提琴:http://jsfiddle.net/charlesbourasseau/m2Cjc/4/
我也嘗試在圈子上使用mousemove而沒有任何成功。
下面是代碼:
var map = new GMaps({
div: '#map',
lat: 52.521832,
lng: 13.413168,
click: function(e) {
var lat = e.latLng.lat();
var lng = e.latLng.lng();
if (circle) {
// TODO how to really remove the circle?
circle.setVisible(false);
}
circle = map.drawCircle({
lat: lat,
lng: lng,
radius: 100,
strokeColor: '#BBD8E9',
strokeOpacity: 1,
strokeWeight: 3,
fillColor: 'transparent'
});
},
mousemove: function(e) {
if (!circle) {
return ;
}
var distance = calculateDistance(circle.getCenter().lat(), circle.getCenter().lng(), e.latLng.lat(), e.latLng.lng());
circle.setRadius(distance);
}
});
謝謝,但我優先考慮AlfaTek的答案:) – Charles
不用擔心,我也是! = d – ezekielDFM