2013-08-29 27 views
-1

更改信息窗口有什麼辦法becouse我需要比基本信息窗口更多的樣式與InfoBoxes到改變信息窗口...與信息框

代碼和演示: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); 

信息窗口不能風格我想要我需要用信息框來改變它,但是如何?

+1

是,編寫代碼。請參閱:http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/docs/examples.html。 – PHPglue

回答

1

這裏是造型信息窗口的好工具:在這個答案http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/examples/example.html

和一些更多的資源:Styling Google Maps InfoWindow

更新: 爲了把一個infobubble你的地圖上可以實現像這樣,有什麼你想在下面選擇。

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); 
    } 
}); 
+0

是的,這應該如何在我的例子? – roaddev

+0

我如何在我的例子中實現? – roaddev

+0

包含那裏包含的infobubble.js文件並傳入所需的選項。或一個信息框,看到上面的評論作出:http://stackoverflow.com/questions/18522195/change-infowindows-with-infobox/18522259?noredirect=1#comment27238715_18522195 –