Why did marker position object change latitude and longitude property names

I am using the Google Maps javascript API in a mobile app. When I first implemented the gmap api, the marker position object had two properties: position.k (latitude) and position.A (longitude). After a few months, the properties changed to position.k (latitude) and position .B (longitude). I am not dreaming, I am very sure that this was the position. in longitude earlier. 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
    });
}
      

Run codeHide result


chrome console capture

Is this the way to google screwingwith us?

+3


source to share


2 answers


Do not use the undocumented properties of the Google Maps API, they can and will change with each release.

Use the documented properties and methods that are for the google.maps.LatLng object :



  • 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
    });
}

      

+4


source


From Google Maps Javascript API: LatLng class is lat: number first and then lng: number.



What you are using is also getPosition () , whose return value is LatLng.

+1


source







All Articles