Skip Navigation

[Resolved] Developing a custom post type to populate map markers

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

Problem: I would like to display Markers on Google Maps but I don't know how to use custom post types to make it work.

Solution: Okay let's say you create a custom post type called "Locations". Then you create an address custom field and associate that custom field with the Locations post type. Now you can manage each Location as a custom post in wp-admin, or using CRED. When you create a Location post, you will give it a title and then add the related address to the custom field. The title will help you find this Location in wp-admin later.

To display the Map with all the Location markers, first insert a Map shortcode in the content of a custom Page somewhere on your site. Note the ID you used for the Map. Then create a View of Locations. In the Loop, insert a Marker shortcode and link it to the Map you just inserted, using the ID you noted earlier. This will add a Marker to the Map for each Location. Then insert your View of Locations on the same Page as the Map.

Now let's say you need to display different Maps that include different Locations, on different Pages. In other words you need a way to filter Locations. You can do this different ways depending on what you want to accomplish. One way is to use another custom field applied to the Location post, another way is to use a taxonomy applied to the Location, and yet another way is to use post relationships. I would need more information about your site to help you make that decision.

Relevant Documentation:
https://toolset.com/documentation/user-guides/display-on-google-maps/

This support ticket is created 6 years, 8 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#636743

Tell us what you are trying to do?

We are attempting to find a way to create a custom post type that will allow us to easily add markers to a specific map on the website. We are unsure of how to create the custom fields/custom post type required and integrate this into the map itself or if this is possible.? We need to find a more organized way to add markers since we will have 100 to 200 to add to a map versus the marker format that is shown in the documentation.

Is there any documentation that you are following?

We have been following this documentation here: https://toolset.com/documentation/user-guides/using-toolset-with-wpbakery-page-builder/list-posts-with-custom-searches-and-maps/

We have also looked at most of the map related posts that are available.

Is there a similar example that we can see?

We don't have a specific example that we are trying to emulate. We are just attempting to create a simple google map with icons that display.

What is the link to your site?

#636946

Okay let's say you create a custom post type called "Locations". Then you create an address custom field and associate that custom field with the Locations post type. Now you can manage each Location as a custom post in wp-admin, or using CRED. When you create a Location post, you will give it a title and then add the related address to the custom field. The title will help you find this Location in wp-admin later.

To display the Map with all the Location markers, first insert a Map shortcode in the content of a custom Page somewhere on your site. Note the ID you used for the Map. Then create a View of Locations. In the Loop, insert a Marker shortcode and link it to the Map you just inserted, using the ID you noted earlier. This will add a Marker to the Map for each Location. Then insert your View of Locations on the same Page as the Map.
https://toolset.com/documentation/user-guides/display-on-google-maps/

Now let's say you need to display different Maps that include different Locations, on different Pages. In other words you need a way to filter Locations. You can do this different ways depending on what you want to accomplish. One way is to use another custom field applied to the Location post, another way is to use a taxonomy applied to the Location, and yet another way is to use post relationships. I would need more information about your site to help you make that decision.

#636985

Hello Christian,

Thanks for your help! It was a simple error we kept committing that was not making the change appear so thanks for helping solve that!

For the data that is displayed in the icon for the map, do we need to create custom fields for this as well or can we automatically pull from the data contained in the post editor?

Thanks in advance

#636986

You can use any combination of Types and Views shortcodes in the Marker content, so you could pull in the post title or post date, any custom field values, the full post content, taxonomy terms, and so on. If this is unique information that does not appear anywhere else, you'll probably need to create a new custom field.