Re: pre-sale GeoCoder plugin questions

5 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 25, 2019   (RSS)

By mbareara - July 22, 2019

In response to: https://www.interactivetools.com/forum/forum-posts.php?postNum=2242776#post2242776

Hi Daniel, 

and if i have results on map from two different tables (or more of course), for example Bar, Brewery, Restaurants, how could  i have different markers for each result?

Thank you in advance for your answer

Orazio 

By daniel - July 24, 2019

Hi Orazio,

Yes, that should definitely be possible. If you're following my example from the other thread, the category that gets passed through can essentially be any value that matches up to the icon name. So you could do something like this instead:

<?php
foreach ($myBarRecords as $record) {
  if (!$record['latitude'] || !$record['longitude']) { continue; }
  $jsFunctionArgs = "{$record['latitude']}, {$record['longitude']}, {$record['num']}, '" .jsEncode($record['_link']). "', 'bar'";
  print "  _geocoder_addMarker($jsFunctionArgs);\n";
}
?>

This would then load these records using the icon filename "icon_category_bar.png", and the loop could be repeated for additional tables.

Let me know if you have any questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

By mbareara - July 24, 2019

hi dave thank you for your answer. 

Just a question

I have this code but how can i modify this part of code to set different icons for different table (restaurant and bar?)

  //
  function _geocoder_addMarker(latitude, longitude, recordNum, detailLink, category) {
    var latLng       = new google.maps.LatLng(latitude, longitude);
    var infowindowEl = document.getElementById('marker_infowindow_' + recordNum);
    var iconPath     = 'http://example.com/map/icon/';
    var marker       = new google.maps.Marker({ map: map, position: latLng, icon: iconPath + 'icon_category_' + 'bar' + '.png' });
    google.maps.event.addListener(marker, 'click', function() {
      if (infowindowEl) {
        infowindow.setContent(infowindowEl.innerHTML);
        infowindow.open(map, marker);
      }
      else {
        window.location = detailLink;
      }
    });
    bounds.extend(latLng);
  }

  //
  map.fitBounds(bounds);
}

By mbareara - July 25, 2019

I forgot to add CATEGORY in this line

function _geocoder_addMarker(latitude, longitude, recordNum, detailLink, category)

Thank You daniel for your great support!

ORazio