Skip Navigation

[Resolved] Displaying maps and markers for each item in a list

This support ticket is created 4 years 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 4 years ago.

Assisted by: Luo Yang.

Author
Posts
#1834807

I have a list of local and national resources associated with college campuses in the US. I'm using a list like the following:
Campus
Category 1
SubCat 1-1
Local Resource 1
Local Resource 2
National Resource 1
SubCat 1-2
etc...

This is created with nested views. Each resource has a Maps Address field associated with it. On the post edit or creation screen, when I put in a location, the API seems to be working and shows the location on a google map.

When I try to drop the Map/Marker into the above loop to display it in the list, it doesn't seem to be working. I probably am not configuring it correctly.

Oh, and I'm not using the block editor to craft the view because I needed to have better control over the HTML/CSS display of the elements, so I'm using the old code editor. Your docs seem to be built around slightly different use cases and based on the block editor.

Question 2: if instead of creating a map for each resource, I instead wanted to make a single map for the campus that showed markers for all associated resources, how would I do that, since I'm displaying the related resources now using this somewhat complex looped list above?

Thanks in advance.

#1835231

Hello,

Please check these:
1) make sure the map ID "map_id" of both map shortcode and marker shortcode are same value
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-render
2) Make sure the marker shortcode ID is unique
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker
3) Make sure you are following our document to setup the Google map API key
https://toolset.com/course-lesson/creating-a-maps-api-key/
4) Check if there is any JS error in your website
https://toolset.com/documentation/programmer-reference/debugging-sites-built-with-toolset/#javascript-debugging

#1835849

When you say the marker ID must be unique, how can that be when they are in a loop? there will be several resources, all created by instances of the same loop, which means they will all have the same ID.

Here is the shortcode in the loop: [wpv-map-render map_id="map-3"][/wpv-map-render][wpv-map-marker map_id='map-3' marker_id='marker-3' marker_field='wpcf-campus-location'][/wpv-map-marker]

'wpcf-campus-location' is the Toolset Address field in the resource post.

Additionally, you didn't address question 2 above, which is how can I pull those local resources into a single map?

Thanks.

#1836031

Q1) When you say the marker ID must be unique
In view's loop, you can use post ID as the marker ID, for example: marker-[wpv-post-id]

Q2) you didn't address question 2 above
I have already addressed the question:

make sure the map ID "map_id" of both map shortcode and marker shortcode are same value

So all markers will display in the map shortcode with the same map ID "map_id"