Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

8 posts by 4 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: August 3, 2017

Hi all,

firstly I am not a php programmer so please bear with me if you think I am talking rubbish.

My goal is to display a google map showing the locations of all our advertisers. The good news is that I have this working, the problem however is Google maps long running issue where if more than one item shares the same postcode it will only drop a pin for one of them , all others are ignored.

This is a huge issue as all our advertisers are based in a small area and many share the same postcode so a large number of our advertisers are not showing on the map. From the research I have done it seems that the only way to resolve this is to slightly alter the latitude or longitude figures slightly for those which have identical postcodes.

This would be nigh on impossible to administrate so was wondering whether there was a way when creating the array for the listing/map page to have each lat/long value checked for duplicate values and then alter the lat or long figures sufficiently to have google drop a pin for it.

As yet I havent found information on how different the lat/long figures need to be to force an individual pin so it would be helpful if anyone has any information/experience with this.

Any help or other working solution for this issue would be appreciated.

Thanks in advance

Hi WillyDoIt, 

Hmm, that's an interesting problem.  What about something like this: 
https://github.com/jawj/OverlappingMarkerSpiderfier

Demo page: https://jawj.github.io/OverlappingMarkerSpiderfier/demo-1.html

If you think that would work I could see if we could create some demo code.

Dave Edis - Senior Developer
interactivetools.com

By willydoit - July 23, 2017 - edited: July 23, 2017

Hi Dave,

This looks as though it would resolve the issue, how would we implement it? i am sure this would help out a lot of geocode users.

My only concern is that on the demo, once you zoom in they dont seem to have pins that have the same postcode which is my issue.  perhaps another solution would be to have a secondary field with an accurate lat and long and have the display code use something like if field "accurate lat" exists use that to display pin else use geocode created lat and long although this would create a lot more admin work.

Hi willydoit, 

First, upload the attached file ("sample_map_multi_spiderfier.php") to /cmsb/plugins/geocoder/examples/ (or the appropriate path on your server).

Try this, at the top of your geocoder.php plugin, add this line in red: 

$GLOBALS['GEOCODER_EXAMPLES']         = array( // these are in /plugins/geocoder/examples
  'sample_form.php'                 => 'Sample form with automatic geocoding',
  'sample_search.php'               => 'Proximity search with results sorted by distance',
  'sample_map_single.php'           => 'Show map with single address',
  'sample_map_multi.php'            => 'Show map with multiple addresses',
  'sample_map_multi_spiderfier.php' => 'Show map with multiple addresses (and OverlappingMarkerSpiderfier)',
);

Then confirm if it works in the examples section: admin.php?_pluginName=geocoder&_pluginAction=examples

Next, copy the example source and adjust it to load your records.

Let me know if that works for you!

Dave Edis - Senior Developer
interactivetools.com

By willydoit - July 29, 2017 - edited: July 29, 2017

Hi Dave,

havent a clue what any of the code does that I had to copy and paste but it works a treat, straight out of the box! a great addition to the geocoder plugin.

One thing I would ask is whether there is any way to make the displayed map responsive?

Thanks.

Hi willydoit, 

Great, glad it's working.  One feature I added after I posted was this option in red: 

  // Overlapping Marker Spiderfier - https://github.com/jawj/OverlappingMarkerSpiderfier
  var oms = new OverlappingMarkerSpiderfier(map, {
    markersWontMove:   true,
    markersWontHide:   true,
    basicFormatEvents: true,
    keepSpiderfied:    true
  });

What it does is keep the "spiderfied" markers open until you click somewhere else on the map so it's easier to click through them.

One thing I would ask is whether there is any way to make the displayed map responsive?

I've never done it but I'm sure it's possible.  What I'd recommend is scanning through some of these google results and see if you can find a relatively simple solution.  It looks like it's possible with some CSS.  If you find something that works well let us know.  https://www.google.ca/search?q=google+maps+responsive

Dave Edis - Senior Developer
interactivetools.com