Question

Is there any way to change infowindow with infoboxes becouse I need more styling than basic infowindows...

CODE AND DEMO: http://jsbin.com/EVEWOta/26

google.maps.event.addListener(marker,'click',function(){
        service.getDetails(request, function(place, status) {
          if (status == google.maps.places.PlacesServiceStatus.OK) {
            var contentStr = '<h5>'+place.name+'</h5><p>'+place.formatted_address;
            if (!!place.formatted_phone_number) contentStr += '<br>'+place.formatted_phone_number;
            if (!!place.website) contentStr += '<br><a target="_blank" href="'+place.website+'">'+place.website+'</a>';
            contentStr += '<br>'+place.types+'</p>';
            if (!!place.photos) contentStr += '<img src=' + place.photos[0].getUrl({ 'maxWidth': 300, 'maxHeight': 300 }) + '></img>';
            infowindow.setContent(contentStr);
            infowindow.open(map,marker);
          } else { 
            var contentStr = "<h5>No Result, status="+status+"</h5>";
            infowindow.setContent(contentStr);
            infowindow.open(map,marker);
          }
        });

    });
    gmarkers.push(marker);

InfoWindows can't style as I want so I need to change it with infoboxes, but how???

Was it helpful?

Solution

Here is a good tool for styling infowindows: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/examples/example.html

And some more resources at this answer: Styling Google Maps InfoWindow

Update: To put an infobubble on your map you can implement it like this, with whatever options you want below.

infoBubble = new InfoBubble({
  map: map,
  content: '<br><a target="_blank" href="'+place.website+'">'+place.website+'</a>',
  shadowStyle: 1,
  padding: 8,
  backgroundColor: 'rgb(57,57,57)',
  borderRadius: 4,
  borderWidth: 5,
  borderColor: '#2c2c2c'
});

google.maps.event.addListener(marker, 'click', function() {
  if (!infoBubble.isOpen()) {
    infoBubble.open(map, marker);
  }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top