Skip Navigation

[Resolved] Multiple post type markers in one map

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

Problem:
Is it possible to have markers on the same map from lots of different post types?

Solution:
Yes. The View to display the map would include all of the different post types in the content selection.

The only requirement would be that each post type uses the same address field for the post location which is used to create the marker.

This support ticket is created 6 years, 1 month 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by cortJ 6 years, 1 month ago.

Assisted by: Nigel.

Author
Posts
#1112134

Hi,

We'd like to have markers for multiple post types to appear on one map. That was possible when I tried for two markers of different post types, but the number could go up to 10 or more for us.

This is the code I used to display two different markers of two post types on one map:


[wpv-map-render map_id="map-16"][/wpv-map-render]
		<wpv-loop>
          [wpv-map-marker map_id='map-16' marker_id='marker-11'  marker_field='wpcf-test-location'][wpv-post-title][/wpv-map-marker]
          [wpv-map-marker map_id='map-16" marker_id='marker-12' marker_field='wpcf-test2-address'][wpv-post-link][/wpv-map-marker]

Would similar code work if we add 10 more markers (each from a different post type) without performance issues? Is there a limit to the number of different post type markers we can/should have in one map?

Thanks.

#1112196

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm not sure if I have understood you correctly.

Let's say you have ten different post types, e.g. hotels, restaurants, museums, shops etc...

You want to display all of them on a single map.

Each post type has an address field.

You create a View and in the Content Selection section to check each of your ten post types.

So now this View is querying the database for all of these post types and returning a mix of them, according to the details of your View.

Then in the output section you add your map.

If each of these post types uses the same address field (e.g. "location"), then you just insert one marker shortcode for that field.

The View will iterate over ("loop" over) the matching posts (of varying types), and for each one add the marker with an address coming from the "location" field.

If some of the post types use a different address field (e.g. "place"), then you would use conditional shortcodes that test for the post type to determine whether you should add a marker for "location" or a marker for "place".

Likewise if you wanted to use different custom markers depending on the post type.

#1113505

Thanks. Glad to know having around ten different fields from different post types in one map can be done.