4

I am using google maps and using markers on the map. When user clicks on any marker showing related information in the Infowindow and every thing is working fine.

But every time the infowindow opens on top of the marker. Our requirement is infowindow should open/come left,right,top or bottom with respective to the available space.

Thanks

 google.maps.event.addListener(marker, 'click', function() {
         if(infowindow){
             infowindow.close();
         }
         infowindow  = new google.maps.InfoWindow();
         //var centerPos = new google.maps.LatLng(latlng.lat(), latlng.lng());
         //map.setCenter(centerPos,65);
         infowindow.setContent(contentString);
         infowindow.open(map,marker);

    });
  • do you have some code to share? – Mapperz Aug 1 '13 at 13:44
  • Please find the code above – user18260 Aug 1 '13 at 13:57
2

The standard info window will only show above the marker. If you want an info window to be positioned elsewhere, you will have to look at the various custom info windows that others have created, or created your own.

  • Ok. If possible could you pls share me the link which fits to my requirement – user18260 Aug 1 '13 at 14:07
  • Here is some code I wrote to accomplish something similar using the ArcGIS Server JavaScript API - you may be able to modify it for Google Maps, using the same logic: forums.arcgis.com/threads/… – Stephen Lead Aug 1 '13 at 14:07
  • Sorry, I thought I'd seen examples out there, but can't find any in particular. There are plenty of examples with labels and tooltips that could be adapted. Also, check out the utilities library (code.google.com/p/google-maps-utility-library-v3/wiki/Libraries), in particular, the InfoBox and InfoBubble might help. – Anthony -GISCOE- Aug 2 '13 at 13:03
2

In your case using InfoBox sounds like the best solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.