Generating multiple maps on multi record page

Looking for a way to create separate maps for a listing page. Each record would have it's own map with clickable marker on it. I have the geocoder plugin, but the example code is for displaying one map on a single page or multiple pins on one map. If anyone has an example, it would be greatly appreciated.

By Dave - October 25, 2020

Hi 28sparks, 

Can you explain a little more about what you're trying to do?  

If each listing page displayed a map with the address for just that listing wouldn't that be a separate map for each listing?

Let me know some more details and we'll try to help.  Thanks!

Dave Edis - Senior Developer
interactivetools.com

By hans - October 28, 2020 - edited: October 28, 2020

Hello there! I will be the one helping you in this issue. Feel free to message if you have any questions afterwards!

The way the method was programmed, only one map was generated by the method. I modified it so that you can add as many maps as you want. 

I have uploaded a replacement of the sample_map_single.php file below. Simply replace the file located at your plugins/geocoder_{version} folder named sample_map_single.php and view it in the Plugins.

jQuery_element_to_append_the_map_to = $("#maps_container");

map = initializeMap({latitude: latitude, longitude: longitude}, jQuery_element_to_append_the_map_to);

You will need jQuery for this.

The parameters are as follows: 

function initializeMap( object properties = {} [, jQuery_element_to_append_to ]){}

under the first parameter properties, there is a required latitude and longitude property, where it contains a latitude, and longitude respectively. It will return a value of the map, and the map's properties.

Hans Marcon
PHP Programmer (In Training)
interactivetools.com
Attachments:

sample_map_single.php 4K

Thanks so much Hans! It worked perfectly. Appreciate the help.

By Codee - October 31, 2020

Hey 28sparks, when you get it done live would you provide a link so we can view it in action?