本文介绍了谷歌地图不显示缩放控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 gmaps.js 插件 http://hpneo.github.com/gmaps/

I am using gmaps.js plugin http://hpneo.github.com/gmaps/

滑动缩放控件和信息窗口不显示并且在显示时存在一些问题.链接:http://bakasura.in/startupsradar/index.html

The Sliding Zoom Control and the InfoWindow don't show up and have some issues when they display. Link: http://bakasura.in/startupsradar/index.html

// JavaScript Document
$(document).ready(function () {
    var map = new GMaps({
        div: '#map',
        lat: 13.00487,
        lng: 77.576729,
        zoom: 13,
    });

    GMaps.geolocate({
        success: function (position) {
            map.setCenter(position.coords.latitude, position.coords.longitude);
        },
        error: function (error) {
            alert('Geolocation failed: ' + error.message);
        },
        not_supported: function () {
            alert("Your browser does not support geolocation");
        },
        always: function () {
            //alert("Done!");
        }
    });

    map.addControl({
        position: 'top_right',
        text: 'Geolocate',
        style: {
            margin: '5px',
            padding: '1px 6px',
            border: 'solid 1px #717B87',
            background: '#fff'
        },
        events: {
            click: function () {
                GMaps.geolocate({
                    success: function (position) {
                        map.setCenter(position.coords.latitude, position.coords.longitude);
                    },
                    error: function (error) {
                        alert('Geolocation failed: ' + error.message);
                    },
                    not_supported: function () {
                        alert("Your browser does not support geolocation");
                    }
                });
            }
        }
    });

    map.addMarker({
        lat: 13.00487,
        lng: 77.576729,
        title: 'Lima',
        icon: "http://i.imgur.com/3YJ8z.png",
        infoWindow: {
          content: '<p>HTML Content</p>'
        }
    });

});

推荐答案

Bootstrap 与 Maps 的渲染发生冲突

Bootstrap was conflicting with the rendering of Maps

添加这些 CSS 行就成功了

Adding these lines of CSS did the trick

/* Bootstrap Css Map Fix*/
#mainBody #map img {
  max-width: none;
}
/* Bootstrap Css Map Fix*/
#mainBody #map label {
  width: auto; display:inline;
}

这篇关于谷歌地图不显示缩放控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 21:21