繁体   English   中英

latLng返回null-Google Maps JavaScript API

[英]latLng returns null - Google maps javascript API

好的,这是文件。 几天前它在工作。 我还没有真正更改任何东西,所以我不知道为什么latLng现在不起作用。

这是我的代码

function map_initialize() {

    var googleMapOptions = {
      center: mapCenter, // map center
      zoom: 17, //zoom level, 0 = earth view to higher value
      maxZoom: 18,
      minZoom: 10,
      zoomControlOptions: {
        style: google.maps.ZoomControlStyle.SMALL //zoom control size
      },
      scaleControl: true, // enable scale control
      mapTypeId: google.maps.MapTypeId.ROADMAP // google map type
    };

    map = new google.maps.Map(document.getElementById("google_map"), googleMapOptions);
    console.log(map);


    //Right Click to Drop a New Marker
    google.maps.event.addListener(map, 'rightclick', function(event) {
      //Drop a new Marker with location Form
      create_marker(event.latLng, 'New Marker', true, true, true);

    });

当我console.log(event.latLng); 它返回一个空对象。

console.log(event.latLng.lat());

尝试使用mousedown侦听器,它的工作原理

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM