Skip Navigation

[Resolved] Using Maps with two custom fields: longitude and latitude

This support ticket is created 2 years, 7 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by TobiasS8611 2 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#2366859
maps1.jpg

Hello,
I have a lot of custom house objects. Evey post has two fields (number), one is latitude and one is longitude

For example:
longitude: 8.42224000000000
latitude: 46.81695480000000

How can I show my custom posts on a map with two custom fields? When I`m configuring the maps in blocks editor, I can choose only one field. And the option "View block" is showing no results.

You can see an test example here: hidden link (needs a bit for loading because of many objects)

#2366895

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tobias,

In order to provide the map with the coordinates from the custom field you will need to use the marker shortcode below.
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker

Using the shortcode like below.

[wpv-map-marker map_id="my-map" marker_id="my-marker" lat='Types shortcode' long='Types shortcode' marker_title="This is a marker" ]This is the content of the marker popup.[/wpv-map-marker]

Notice the Long and lat attributes in the shortcode.

Please let me know if this helps.
Thanks,
Shane

#2367555

Hi Shane,

thanks for your reply. Where do I have to insert the shortcode? And what means "Types shortcode" for lat and long? Is ist the custom field name (in my example "latitude") or ist is the Types Shortcode like [types field='latitude' format='FIELD_VALUE'][/types]?

Kind regards,
Tobias

#2367663

Ok, I think I got the code now:

[wpv-map-marker map_id="cote-dazur" marker_id="marker-4" lat="[types field='latitude' format='FIELD_VALUE'][/types]" lon="[types field='longitude' format='FIELD_VALUE'][/types]" marker_title="Ferienhaus"]This is the content of the marker popup.[/wpv-map-marker]

But where do I have to import this (using blocks editor)??

#2367741

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Tobias,

That's correct. The shortcode will need to be added to a Classic block or the Fields and Text block.

So long as the map block is on the page and the the map id in the marker shortcode is correct then it should populate your map with the correct markers.

Thanks,
Shane

#2369287

Hi Shane, thanks for helping me. I used the Fields and Text block and imported the code there. Then I made the field invisible. All objects are shown in the maps. Thank you!