Skip Navigation

[Resolved] How to use the Longitude and Latitude fields in a view?

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to display lat and long with your map address field.

Solution:
To display lat and long with your types address field:
1) Click on "Field and views" button,
2) Find you custom address field and try to add it (just like other custom field you add to view)
3) A popup will be opened up and there you will find settings to get lat and long.

It will add shortcode as follows:

[types field="location-address" format="FIELD_ADDRESS: FIELD_LATITUDE, FIELD_LONGITUDE"][/types]

Relevant Documentation:

This support ticket is created 8 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 8 replies, has 3 voices.

Last updated by Timothy 8 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#359687

I'm using the toolset maps plugin and the Address custom field. I see that when I enter an address in it automatically creates Longitude and Latitude coordinates (Show/Hide coordinates) in my custom post type. I'd like to use those in a View in order to output a map but I'm not sure how to do that.

I thought maybe these would work but they don't seem to:
[types field="longitude" output="raw"][/types]
[types field="longitude" output="raw"][/types]

What I'm trying to do is output an image of a map using those coordinates, for example:

<img src="<em><u>hidden link</u></em>">

So ideally something like this would do it:

<img src="<em><u>hidden link</u></em> field="latitude" output="raw"][/types],[types field="longitude" output="raw"][/types]">

Tim

#359709

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I need to check how you configured your map and view. Could you please send me link of the page where you've insert your view.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#359713

Hi Tim,
You can't get at the lat lng values from the address field (unless you use jquery or similar). But you do have new fields in your Views to add a map and a marker for your address.
You can find out how in this article - https://toolset.com/documentation/user-guides/display-on-google-maps/

#359724
Screen Shot 2016-01-15 at 8.41.50 PM.png

Thanks Simon, but the Address field that the ToolSet Maps adds automatically generated coordinates from the input address, you can see form the screenshot. Shouldn't I just be able to fetch those and use them in a view?

#359728

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The address field you are using is Types custom field?

If yes, then you should click on "Field and views" button, find you custom address field and try to add it (just like other custom field you add to view) and a popup will be opened up and there you will find settings to get lat and long.

If you dont find that, as requested before, could you please send me access details.

#359742

No Tim, the lat lng is not persisted, just the address string. You can use a little jquery to capture them and pop them into custom fields on your post, but there is no 'out of the box' way to get them - only the address string is saved to the db.
You can add a map object to your view (it's available from the fields button) and a marker object in your view. This will display a marker at the lat/lng specified by the address (but it is always using the address and not lat/lng).

#359848

Simon, are you sure it's not persisted? It's actually working for me. I'm using this in a View and the output is correct, a google map image if the correct address.

<img src="hidden link field="location-address" format="FIELD_ADDRESS: FIELD_LATITUDE, FIELD_LONGITUDE"][/types]">

So it would seem that the coordinates are saved in the database and can be used with:
[types field="location-address" format="FIELD_ADDRESS: FIELD_LATITUDE, FIELD_LONGITUDE"][/types]

Tim

#359857

Hi Tim,
Yep sure, it is cached, but it's not saved to the db - if you are pulling lat/lng, then it's either coming from cache or from geocoding the address on the fly. I'd be surprised if this doesn't change in the future. Take a look at phpmyadmin to check the field content.
Having said that, in your example above, it would be appear to be academic - as you can retrieve your lat/lng from the address.
If you are using the address field in a cred form or in the admin backend, you cannot set a lat/lng. If you try to drag the marker, you are not really positioning it, it will always snap to an address, normally based on locality or sub-locality (Town level).

#359916

Thanks for the details Simon, but what do you mean by " I'd be surprised if this doesn't change in the future."?

Tim

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.