有两个地方我需要显示谷歌地图.我对两个地图使用相同的代码(我的意思是我重复使用两个地图的相同代码).以下是可以找到这两张地图的屏幕截图的链接.
https://drive.google.com/file/d/0B2JnvvXsAALUdlVzemRVMzNMajF4OFB1V0JXc0RuN1p4eWFV/view - map1
https://drive.google.com/file/d/0B2JnvvXsAALUVGRhNm1HSldhQnpZT3k4S2I2R1YyQkp4OWZz/view - map2
我在bootstarp模式中显示第二个地图(map2)
第一张地图(map1)工作正常.但是在第二张地图(map2)中,虽然我使用了setCenter方法,但是标记没有显示在地图的中心(而是显示在左上角).我该怎么做才能将标记放在地图的中心(在第二张地图中)?
下面是我的代码..
initialize: function(options){
//initializing the geocoder
this.geocoder = new google.maps.Geocoder();
this.map;
},
//on show of the view
//onShow is a marionette method, which will be triggered when view is shown
onShow: function(){
var address = this.model.get("address");
//render the map with dummy latLang
this.renderMap();
//render the Map with Proper address
if(address!== ""){
this.renderMapWithProperAddress(address);
}
},
renderMap: function(){
var mapCanvas = document.getElementById("mapCanvas"), self = this,
mapOptions = {
center: new google.maps.LatLng(64.855, -147.833),//dummy latLang …Run Code Online (Sandbox Code Playgroud)