-1
ユーザーがGoogleマップをハードコーディングするのではなく、そのポリゴンをクリックしようとしています。 https://jsfiddle.net/vL6qpn4w/4/Googleマップのマウスクリックでポリゴンを描く方法
どれsugesstion:
それは.This作成することができませんが、私のコードは
function initMap() {
var mapDiv = document.getElementById('map');
var mapOptions= {
center: new google.maps.LatLng(23.09024, -90.417924),
zoom: 7,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(mapDiv,mapOptions)
google.maps.event.addListener(map, 'click', function(event){
var Latitude=event.latLng.lat();
var Longitude=event.latLng.lng();
var destinations=new google.maps.MVCArray();
destinations.push(new google.maps.LatLng(Latitude,Longitude));
console.log(destinations)
var polygonOptions={path:destinations,strokeColor:"#ff0000",fillColor:"00ff00"};
var polygon=new google.maps.Polygon(polygonOptions);
polygon.setMap(map);
});
}
フィドルのですか?
私はあなたがカスタムイベントハンドラを作成した参照しながら、Googleはすでに描画ライブラリを持っている、確認し、[この](https://developers.google.com/maps/ documentation/javascript/drawinglayer)を出してください。 –
@ G.Hunt thanks.Canあなたはこの質問の譲歩をお願いします。https://stackoverflow.com/questions/46152951/how-can-i-get-coo-ordinates-with-drawing – user7397787