如何在谷歌地图中获得Lat,Long价值的点击事件

时间:2018-09-05 08:32:29

标签: angular6

mapProp = {
    center: new google.maps.LatLng(24.8607, 67.0011),
    zoom: 11,
    mapTypeId: google.maps.MapTypeId.TERRAIN
};
<div id="map" style="width:50%;height:185px" float:right>
            <div #gmap style="width:100%;height:100%"  (mapClick)="placeMarker($event)"></div>
            <span class="marker"><i class="fa fa-map-marker"></i></span>
        </div>
placeMarker($event){
    google.maps.event.addListener(this.mapProp, 'click', function( event ){
        alert( "Latitude: "+event.latLng.lat()+" "+", longitude: "+event.latLng.lng() );            
    });
}

0 个答案:

没有答案