Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps 使用fromLatLngToPoint()将V2转换为V3时,值不会出现_Google Maps_Google Maps Api 3_Google Maps Api 2 - Fatal编程技术网

Google maps 使用fromLatLngToPoint()将V2转换为V3时,值不会出现

Google maps 使用fromLatLngToPoint()将V2转换为V3时,值不会出现,google-maps,google-maps-api-3,google-maps-api-2,Google Maps,Google Maps Api 3,Google Maps Api 2,我正在将代码V2转换为V3,下面的代码是googlemapV2code。在警报sw.x中出现了一些值 //Google map V2 code: function flagIntersectingMarkers() { var pad = this.borderPadding; var zoom = this.map.getZoom(); var projection = this.map.getCurrentMapType().getProjection();

我正在将代码
V2
转换为
V3
,下面的代码是
googlemap
V2
code。在警报
sw.x
中出现了一些值

//Google map V2 code:
function flagIntersectingMarkers()  {
   var pad = this.borderPadding;
       var zoom = this.map.getZoom(); 
   var projection = this.map.getCurrentMapType().getProjection();
   var bounds = this.map.getBounds();
   var sw = bounds.getSouthWest();
   sw = projection.fromLatLngToPixel(sw, zoom);
   alert("sw"+sw.x); // In this alert some value is coming
   sw = new GPoint(sw.x-pad, sw.y+pad);
  sw = projection.fromPixelToLatLng(sw, zoom, true);
 }

//Google map V3 code:
function flagIntersectingMarkers()  {
   var pad = this.borderPadding;
       var zoom = this.map.getZoom();
   var projection = this.map.getProjection();
   var bounds   = this.map.getBounds();
   var sw = bounds.getSouthWest();
   sw = projection.fromLatLngToPoint(sw, zoom);
   alert("sw"+sw.x); // Undefined value is coming
   sw = new google.maps.Point(sw.x-pad, sw.y+pad);
   sw = projection.fromPointToLatLng(sw, zoom, true);
 }

但是在上面的
V3
代码中,在即将到来的警报
sw.x
未定义值中,如何在
V3
中检索
sw.x
值您面临的问题是您没有将一些调用正确地从v2转换到V3,并且没有检查方法的参数列表。确保


您好,任何人都可以为V2到V3的迁移提供帮助。我正在提醒投影值,它显示为object。如何打印对象?请帮忙。!!!如果您在jsfiddle上发布了一个完整的v2代码工作示例,以及map,If将非常有用。
//Google map V3 code:
function flagIntersectingMarkers()  {
   var pad = this.borderPadding;
   var zoom = this.map.getZoom();              // Returns number
   var projection = this.map.getProjection();  // Returns Projection
   var bounds   = this.map.getBounds();        // Returns LatLngBounds
   var sw = bounds.getSouthWest();             // Returns LatLng
   var swpt = projection.fromLatLngToPoint(sw); // WRONG in original code 2nd argument is Point, and not needed, plus should not overwrite sw
   alert("swpt"+swpt.x); // Should be defined now
   swptnew = new google.maps.Point(swpt.x-pad, swpt.y+pad); // Build new Point with modded x and y
   swnew = projection.fromPointToLatLng(swptnew, true);  //Build new LatLng with new Point, no second argument, true for nowrap
}