【问题标题】:Google maps control is not showing谷歌地图控件未显示
【发布时间】:2013-08-18 14:53:03
【问题描述】:

我在我的联系页面上嵌入了谷歌地图,但谷歌放大/缩小不起作用,以及如何添加信息框 这是我的链接

http://www.spheretekk.com/safari/map-lax.html

这是我在 chrome 中的屏幕截图

http://www.safarikidindia.com/ss.jpg

这是我的 uodated js

 < script type = "text/javascript" >

 function initialize() {
//Initalize JS after onload
var map = new google.maps.Map(document.getElementById('map_canvas'), {

    mapTypeId: google.maps.MapTypeId.ROADMAP,
});




var randomPoint0 = new google.maps.LatLng(22.59373, 72.94922);
//First Location


var marker0 = new google.maps.Marker({
    //Set up marker
    position: randomPoint0,
    map: map
});

google.maps.event.addDomListener(document.getElementById('locationid0'), 'click', //Set up DOM listener 1
function () {
    map.setZoom(13);
    map.setCenter(marker0.getPosition());

});




var randomPoint1 = new google.maps.LatLng(19.01626, 72.84019);
//First Location
var contentString = '<div id="content">' +
    '<div id="siteNotice">' +
    '</div>' +
    '<h2 id="firstHeading" class="firstHeading">Uluru</h2>' +
    '<div id="bodyContent">' +
    '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' +
    'sandstone rock formation in the southern part of the ' +
    'Northern Territory, central Australia. It lies 335 km (208 mi) ' +
    'south west of the nearest large town, Alice Springs; 450 km ' +
    '(280 mi) by road. Kata Tjuta and Uluru are the two major ' +
    'features of the Uluru - Kata Tjuta National Park. Uluru is ' +
    'sacred to the Pitjantjatjara and Yankunytjatjara, the ' +
    'Aboriginal people of the area. It has many springs, waterholes, ' +
    'rock caves and ancient paintings. Uluru is listed as a World ' +
    'Heritage Site.</p>' +
    '<p>Attribution: Uluru, <a href="http://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">' +
    'http://en.wikipedia.org/w/index.php?title=Uluru</a> (last visited June 22, 2009).</p>' +
    '</div>' +
    '</div>';

var infowindow = new google.maps.InfoWindow({
    content: contentString
});

var marker1 = new google.maps.Marker({
    //Set up marker
    position: randomPoint1,
    map: map
});

google.maps.event.addDomListener(document.getElementById('city'), 'change', //Set up DOM listener 1
function () {
    map.setZoom(13);
    map.setCenter(marker1.getPosition());

});









map.setCenter(marker0.getPosition());
map.setZoom(5);
 }
 google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
 });



 < /script>

我错过了什么或做错了什么?

【问题讨论】:

标签: css google-maps google-maps-api-3


【解决方案1】:

看起来您还没有添加控件的选项,或者至少没有添加缩放控件。

https://developers.google.com/maps/documentation/javascript/controls#Adding_Controls_to_the_Map

基于此,您似乎需要在 Initialize 之后添加它们。

【讨论】:

    【解决方案2】:

    问题应该是因为通用img{max-width: 100%;}

    在你的 CSS 中试试这个

    .gmnoprint img {
        max-width: none; 
    }
    

    【讨论】:

      【解决方案3】:

      在你的 CSS 中试试这个

      .gmnoprint>* {
          left: 0;
      }
      

      【讨论】:

        猜你喜欢
        • 2019-01-21
        • 2012-03-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-15
        • 2012-06-25
        • 1970-01-01
        相关资源
        最近更新 更多