1
votes

I try to open a selected window(s, e.g. infWin1, or infWin2, or both) in gmap3 plugin on map loaded - not on click, or hover.

Code is attached.

Any help, hint would be appreciated.

$('#googleMap')
    .gmap3(
    { action:'init',
        options:{
        center:[49.651626,2.145664],
        zoom: 15
        }
    },

    { action: 'addMarkers',
        markers:[
            {lat:49.628059, lng:2.117512, data:"some infoWin lbl"}, //infWin1
            {lat:49.59558, lng:2.121529, data:"some other infoWin lbl"} //infWin2
            ], 
        marker:{
          options:{
              draggable: false
          },
          events:{
              click: function(marker, event, data){

              var map = $(this).gmap3('get'),
              infowindow = $(this).gmap3({action:'get', name:'infowindow'});
              if (infowindow){
                  infowindow.setOptions({maxWidth:250});
                  infowindow.open(map, marker);
                  infowindow.setContent(data);
              } else {
                  $(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data,maxWidth:250}});

              }
              }
          }

          }
      }

      ,{action:"autofit"}

      );

2

2 Answers

0
votes

so, just add it in the high lever of the request, not in the event

Notice that version 5.0 has been released last week

0
votes

Change the click event to mouseover

marker:{
      options:{
          draggable: false
      },
      events:{
          mouseover: function(marker, event, data){

          var map = $(this).gmap3('get'),
          infowindow = $(this).gmap3({action:'get', name:'infowindow'});
          if (infowindow){
              infowindow.setOptions({maxWidth:250});
              infowindow.open(map, marker);
              infowindow.setContent(data);
          } else {
              $(this).gmap3({action:'addinfowindow', anchor:marker, options:{content: data,maxWidth:250}});

          }
      }
}