为什么标记位置对象更改经度和纬度的属性名称 [英] Why marker position object changed latitude and longitude property names

查看:170
本文介绍了为什么标记位置对象更改经度和纬度的属性名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用谷歌地图API的JavaScript的移动应用程序。
当我第一次实现了GMaps实现API,标记位置对象有两个属性:
position.k(纬度)和 position.A (经度)。数个月左右之后的属性变更为
position.k(纬度)和 position.B (经度)。我不是在做梦,我非常非常肯定这是的 position.A 经度之前。我测试了它。

\r
\r

函数saveNewGeoLocation(){\r
VAR位置= zx.currentMarker.getPosition();\r
    $ .getJSON(/?Serv.svc / UpdateGeoLocation+ $ .PARAM({纬度:position.k,经度:position.B,someotherparam:someValue中}),功能(数据){\r
        //其他一些code\r
    });\r
}

\r

\r
\r

这是谷歌的的与我们ING?办法


解决方案

不要使用谷歌地图API的无证特性,它们可以并且将与每一个版本更改。

使用的文件的属性和方法,这对于一个 google.maps.LatLng物件是:


  • 纬度()|号|返回度的纬度。

  • LNG()|号|返回度经度。

 函数saveNewGeoLocation(){
    VAR位置= zx.currentMarker.getPosition();
    $ .getJSON(/ Serv.svc / UpdateGeoLocation?+ $ .PARAM({纬度:position.lat(),经度:position.lng(),someotherparam:someValue中}),功能(数据){
        //其他一些code
    });
}

I'm using Google Maps javascript API in a mobile application. When I first implemented the gmaps api, the marker position object had two properties: position.k (latitude) and position.A (longitude). After a few months or so the properties changed to position.k (latitude) and position.B (longitude). I'm not dreaming, I'm very very sure it was position.A for longitude before. I tested it.

function saveNewGeoLocation() {
	var position=zx.currentMarker.getPosition();
    $.getJSON("/Serv.svc/UpdateGeoLocation?" + $.param({ latitude: position.k, longitude: position.B, someotherparam:"somevalue" }), function (data) {
        //some other code
    });
}

Is this Google's way of ing with us?

解决方案

Don't use undocumented properties of the Google Maps API, they can and will change with every release.

Use the documented properties and methods, which for a google.maps.LatLng object are:

  • lat() | number | Returns the latitude in degrees.
  • lng() | number | Returns the longitude in degrees.

function saveNewGeoLocation() {
    var position=zx.currentMarker.getPosition();
    $.getJSON("/Serv.svc/UpdateGeoLocation?" + $.param({ latitude: position.lat(), longitude: position.lng(), someotherparam:"somevalue" }), function (data) {
        //some other code
    });
}

这篇关于为什么标记位置对象更改经度和纬度的属性名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆