Skip Navigation

[Resolved] Adding shapes to already rendered maps.

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

Problem:
The customer wants to add shapes to a map rendered by Toolset. They have geoCoordinates and wish to use the Google Maps addJSON feature but encounter difficulties because the map is already rendered by the time they can access it with JavaScript.

Solution:
I recommended using the js_event_wpv_addon_maps_init_map_completed event listener to run scripts when the map is rendered. An example was provided to adapt for adding a background color to a map area after rendering.

Upon trying the provided code, the customer encountered errors in the JS console and the shapes did not render as expected. Further investigation and temporary site access were requested to diagnose and resolve the issue. However, the customer was able to move forward with the original reference and resolved their issue.

Relevant Documentation:
https://developers.google.com/maps/documentation/javascript/examples/layer-data-polygon#maps_layer_data_polygon-javascript
https://developers.google.com/maps/documentation/javascript/datalayer
https://toolset.com/forums/topic/i-need-to-add-area-on-a-toolset-map/

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 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 3 replies, has 2 voices.

Last updated by Mateus Getulio 5 months, 2 weeks ago.

Assisted by: Mateus Getulio.

Author
Posts
#2700582

Tell us what you are trying to do?
Hello, I would like to know how to add a shape to the map that is already rendered. All of the Google Maps documentation seems to be for people that are initializing the maps, but since the maps are being initialized by toolset, I was wondering if you have guidance for how to add things to the map beyond markers.

Specifically, we have geoCoordinates that can draw shapes on certain Maps. I was hoping to use the Google Maps addJSON feature, but I can't seem to connect the dots since the map is already rendered by the time I can access it with JS.

Is there any documentation that you are following?
hidden link

and

hidden link

Is there a similar example that we can see?

What is the link to your site?

battstaging.com

#2700776

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

You can use listener js_event_wpv_addon_maps_init_map_completed to run scripts when the map is rendered.

Please check this example where it was needed to add a background color to a map area after it rendered and see if you can adapt it to work for you:

https://toolset.com/forums/topic/i-need-to-add-area-on-a-toolset-map/

Thank you,
Please let us know.

#2700803
Screenshot 2024-06-03 at 4.19.02 PM.png

Hello Mateus,

Thanks so much for this link. Yes it looks like it's what I need, except when I paste the provided code into the Toolset JS editor as suggested, I don't get the expected shape rendering in the city of Santa Cruz. Instead, I get a number of errors that show up in the JS console.

The name of the view is "Map View," and I expected it to render on the homepage here:

hidden link

THANKS

#2701095

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://toolset.com/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

**IMPORTANT**

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

Please, let me know if you need any additional details. Have a nice day.

#2701513

Thank you!

I realized that your original reference helped us move forward. We have one last unrelated question but I will open a separate ticket for that. Thanks again!

Max