I am experimenting/learning how to use GeoJson data on a Google Maps Datalayer. I managed to get the co-ordinates to display in a popup by using getGeometry().get()
.
我正在试验/学习如何在Google Maps Datalayer上使用GeoJson数据。我设法通过使用getGeometry()。get()来使坐标显示在弹出窗口中。
Is there however a way to get separate lat
and lng
like you would with latLng.lat(), latLng.lng()
or would I have to use something like regex to split it to lat and lng?
有没有办法像latLng.lat(),latLng.lng()一样获得单独的lat和lng,或者我必须使用像regex这样的东西将它拆分为lat和lng?
I am currently only able to get co-ordinates like this:
我目前只能得到这样的坐标:
var coordinates = Event.feature.getGeometry().get();
1 个解决方案
#1
2
The .get()
function returns a LatLng*, so you should be able to call .lat()
and .lng()
directly on it, or .toString()
or any of the LatLng methods, e.g. this should work:
.get()函数返回一个LatLng *,因此您应该能够直接在其上调用.lat()和.lng(),或.toString()或任何LatLng方法,例如:这应该工作:
var coordinates = Event.feature.getGeometry().get();
var lat = coordinates.lat();
var lng = coordinates.lng();
#1
2
The .get()
function returns a LatLng*, so you should be able to call .lat()
and .lng()
directly on it, or .toString()
or any of the LatLng methods, e.g. this should work:
.get()函数返回一个LatLng *,因此您应该能够直接在其上调用.lat()和.lng(),或.toString()或任何LatLng方法,例如:这应该工作:
var coordinates = Event.feature.getGeometry().get();
var lat = coordinates.lat();
var lng = coordinates.lng();