Back to Google Maps Widgets Support

hatalias9106
hatalias9106

I need the separate coordinates to load into a project. current: {{post.latlng}} = {"lat": xxx, "lng": xxx}

I need it as soon as I carry something like this. {{post.latlng.lat}} = xxx

Fencus
Fencus

Hi hatalias,

{"lat": xxx, "lng": xxx}

Is a JavaScript object.

You can process it as one:

https://www.w3schools.com/js/js_objects.asp

Read under "Accessing Object Properties".

Or check this example of how to work with JS objects:

https://www.w3schools.com/js/tryit.asp?filename=tryjs_objects_properties_2

The object is saved to be used in the Google Maps API, so, you need to use {{post.latlng}} in a script tag and then use that as an object to get "lat" or "lng", but you will need some minor knowledge of JS (easy to do with a little reading on the internet). Let me know if you need some clarification or additional help.

Last updated

hatalias9106
hatalias9106

Is it not possible to get these values via component? because I need to load 134 posts on a page, I would like to pull those values straight.

Fencus
Fencus

hatalias9106 said:

Is it not possible to get these values via component? because I need to load 134 posts on a page, I would like to pull those values straight.

Sorry, that's not possible. You can make a script for each post, assuming that each post has a different value. But you have to handle the lat/lng discrimination with JS, because that is how the value is stored in the database. Again, sorry, but the widget was made to work with maps rather than with raw lat/lng. A positive side is that you can make the value maybe a little more "readable", I'm assuming (I don't recall from memory) that the value is saved as a decimal, like 34,423929213 or something like that, using JS you can at the same time maybe get something like 34ยบ 28' 33''.

Last updated

hatalias9106
hatalias9106

Thank you for your help.

1-5 of 5