简体   繁体   中英

Convert LatLng (the return value from computeoffset() ) to object literal

var point = new google.maps.LatLng(10.398671, -84.170756);   
 google.maps.geometry.spherical.computeOffset(point, 100, 0);

The returned value from computeoffset is (..., ...). Then how to convert it to {lat: ..., lng: ...}?

A google.maps.LatLng has methods for latitude and longitude:

var point = new google.maps.LatLng(10.398671, -84.170756);   
var newpt = google.maps.geometry.spherical.computeOffset(point, 100, 0);
var pt = {lat: newpt.lat(), lng: newpt.lng()};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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