如何在Div中显示Google Map缩放级别

时间:2018-08-16 20:31:01

标签: javascript geocoding

如何像标签一样显示Div内的Google Map缩放级别。

有点像图像

enter image description here

这是我的代码:

        function myMap() {
            var myCenter = new google.maps.LatLng(56.1304, -106.3468);
            var mapProp = { center: myCenter, zoom: 6, scrollwheel: true, draggable: true, mapTypeId: google.maps.MapTypeId.ROADMAP };
            var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
         
            marker.setMap(map);
        }
<div style="padding: 0px; padding-top:2px; padding-right:2px; width:25px; height: 25px; background-color: #fff; font-size:18px; border: solid 1px #777; text-align:center; vertical-align:middle; font-weight:bold;">
    display zoom level here
</div>

1 个答案:

答案 0 :(得分:2)

您可以使用similar question中所述的代码。将缩放更改侦听器添加到地图,然后将div内容设置为每次更改的新缩放。

dat <- structure(list(ID = c("BHS_1149", "BHS_1154", "BHS_1155", "BHS_1156", 
"BHS_1157", "BHS_1159", "BHS_1169", "BHS_1259", "BHS_1260", "BHS_1262", 
"BHS_1262", "BHS_1262", "BHS_1262", "BHS_1262"), Date = structure(c(1491890400, 
NA, NA, NA, NA, 1491890400, 1491890400, NA, NA, 1491890400, 1499234400, 
1512543600, 1512543600, 1516172400), class = c("POSIXct", "POSIXt"
), tzone = ""), Fate = c("MIA", NA, NA, NA, "Mort", "Alive", 
"Alive", NA, NA, "MIA", "Alive", "Alive", "MIA", "Mort")), row.names = c(NA, 
-14L), .Names = c("ID", "Date", "Fate"), class = "data.frame")