Page 1 of 1

[SOLVED] How to get markers list in CGGoogleMaps2

Posted: Mon Aug 25, 2014 9:42 am
by blast2007
Just upgrade from CGGoogleMaps (where I used sidebar) and I have no idea how to achieve this on CGGoogleMaps2.

I read on module help section "Users developing applications centered around a map can modify the map template of their map to quite easily add a sidebar." :) funny But how?

Any clues?
Best regards

Re: How to get markers list in CGGoogleMaps2

Posted: Tue Aug 26, 2014 10:06 am
by blast2007
Now I got markers list with getMarkerList() but I don't know how to open infowindow for a single marker...
...anyone?
I can't understand if nobody use this module yet. Too new?

Thanks and regards
b.

Re: How to get markers list in CGGoogleMaps2

Posted: Thu Aug 28, 2014 8:21 am
by blast2007
---- up ----

Re: How to get markers list in CGGoogleMaps2

Posted: Thu Aug 28, 2014 4:14 pm
by calguy1000
use the showInfoWindow method.

Re: How to get markers list in CGGoogleMaps2

Posted: Thu Aug 28, 2014 8:27 pm
by blast2007
Thanks for your help but I'm really in trouble with all this CGclass* and its methods.
My map template is this:

Code: Select all

...
<div id="underbar"></div>
{* javascript is on the bottom incase some smarty variables we need were set in the various generator calls *}
<__script__ type="text/javascript">
if( typeof(jQuery) == 'undefined' ) {
  var div = document.getElementById('cggm_map_{$mapinstance}').
  div.innerHTML = '<h3 style="color: red;">jQuery and jQuery UI Are Required</h3>';
  throw new Error('jQuery and jQuery UI Are Required');
}
$(document).ready(function(){
  var obj = $('#cggm_map_{$mapinstance}');
  obj.cggm2({$generator->get_map_options_js()});

  var myobj = obj.cggm2('getMarkerList');

  for (var i = 0; i < myobj.length; ++i) {
  $("#underbar").append( myobj[i].value + " - " +    myobj[i].text + "<br />");
...
Now I understand how to show markers list but I can't understand how to use showInfoWindow method on this list!

regards

Re: How to get markers list in CGGoogleMaps2

Posted: Thu Aug 28, 2014 9:33 pm
by calguy1000
It really isn't that hard.

a: build your sidebar, given the marker names
(each item should be a separate block, and inside that block you can have a link)
a structure something like <a class="showinfowindow" data-marker-name="some_place">Some Place</a>
b: add a jquery event handler function to trap a click on a sidebar item
- retrieve the marker name
- call obj.cggm2('showInfoWindow',the_marker_name');

Code: Select all

$('#sidebar a.showinfowindow').click(function(){
   var the_marker_name = $(this).data('marker-name');
   obj.cggm2('showInfoWindow',the_marker_name);         
});

Re: How to get markers list in CGGoogleMaps2

Posted: Fri Aug 29, 2014 6:20 am
by blast2007
YEEEESSSSSS IT WORKSSS!!!

Thanks so much calguy1000!!!

Best regards
blast