Google Maps Doesn't Show Zoom Controls

2020-02-09 02:00发布

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

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

enter image description here

// 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>'
        }
    });

});

2条回答
Summer. ? 凉城
2楼-- · 2020-02-09 02:05

Bootstrap was conflicting with the rendering of Maps

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; 
} 
查看更多
萌系小妹纸
3楼-- · 2020-02-09 02:10

I had this before, it was some of my own CSS that overwrote some of the values in maps. I would suggest checking all styles applied to img tags. Especially width values that is set to images globally.

查看更多
登录 后发表回答