Why getProjection() is not working in V3

前端 未结 1 1165
醉话见心
醉话见心 2020-12-19 05:54

According to the API ref, the map object should have a getProjection method:
http://code.google.com/apis/maps/documentation/v3/reference.html#Map

While loading

相关标签:
1条回答
  • 2020-12-19 06:37

    It isn't available until the map is finished initializing. You have to wait on the "projection_changed" event before accessing it.

    function initialize() {
     var mapOptions = {
       zoom: 8,
       center: new google.maps.LatLng(-34.397, 150.644),
       mapTypeId: google.maps.MapTypeId.ROADMAP
       };
     map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);
     google.maps.event.addListenerOnce(map,"projection_changed", function() {
       alert("projection:"+map.getProjection());
     });
    }
    
    0 讨论(0)
提交回复
热议问题