Skip Navigation

[Resolved] Google Map – filter/show lines drawn on certain roads

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.

This topic contains 2 replies, has 2 voices.

Last updated by georgeY-3 1 year, 11 months ago.

Author
Posts
#2554623

I have hundreds of dirt roads I've drawn on a custom Google Map in My Maps. Each road has a marker. I also have a Google sheet with the road names and other data that I'd like to show along side the map. I would like when a user clicks a road in the list it will show in the map. Is this possible using Toolset?

#2554845

Nigel
Supporter

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

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

Hi there

You are looking at a highly customised solution here that would involve custom coding, certainly JavaScript, and possibly PHP, too.

First you need to get your spreadsheet data in, which involves setting up post types (e.g. "road") and custom fields for the data relating to each road. You would need to use an import plugin for that, see the guide here: https://toolset.com/course-lesson/how-to-import-content-into-wordpress-using-csv/

You would use a View to display the list of roads, and a map.

You can get the JavaScript map object (to be able to update the map options) with

WPViews.view_addon_maps.get_map( map_id );

(Here's an example of doing that to draw circles on the map: hidden link.)

You would need to consult the Google Maps documentation for how to draw roads on the map.

I expect that when outputting the list of roads, whatever data is needed to be able to draw a road would be included as data attributes on the link you would attach a click event listener to to trigger the code to draw the road.

That's the approach I would take, but, as I say, it involves quite a bit of custom code, and if that's not something you are comfortable with you would need to recruit a developer to do it for you, e.g. via https://toolset.com/contractors/

#2555187

Thanks for your well thought out reply. I was thinking it might require some custom JS. No, I'm not a programmer, but I think ChatGPT might be able to help with that part.