簡體   English   中英

在移動地圖中心之前看不到Google Maps v3中的繪圖多邊形

[英]Can't see drawing polygon in Google maps v3 till move the map center

我有以下演示 ,嘗試使用Google Maps v3繪制多邊形。

但是,當我嘗試繪制多邊形時,直到我更改地圖中心才將其隱藏。

我需要重新粉刷嗎?

這是代碼:

var map2;

function linesmap(){

    var myOptions = {
    zoom: 14,
    center: new google.maps.LatLng(51.425, -0.955),
    mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    // map2 = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

     var options = {                                
                         zoom: 14,
                         center: new google.maps.LatLng(51.425, -0.955),
                         mapTypeId: google.maps.MapTypeId.ROADMAP,
                         panControl: false,
                         scrollwheel: true,
                         draggable: true,
                         rotateControl: false,
                         mapTypeControl: true,
                         scaleControl: true,
                         streetViewControl: true,
                         zoomControl: true,
                         disableDoubleClickZoom: false
    };


    map2 = new google.maps.Map(document.getElementById("map_canvas"), options);
    buildDrawManager();
}
var buildDrawManager = function(){
     console.log('buildDrawManager');

     // Creates a drawing manager attached to the map that allows the user to draw
     // markers, lines, and shapes.
     drawingManager = new google.maps.drawing.DrawingManager({
     drawingMode: null,
     drawingControlOptions: {
                position: google.maps.ControlPosition.TOP_CENTER,
                drawingModes: [
                google.maps.drawing.OverlayType.POLYGON
                ]
            },
            polygonOptions: {
                fillColor: '#1E90FF',
                strokeWeight: 0,
                fillOpacity: 0.3,
                editable: true
            },
            map: map2
        });

    google.maps.event.addListener(drawingManager, 'polygoncomplete',  function(polygon) { });

}

[編輯]

它發生在Chrome版本32.0.1700.76

@fessy您的修復似乎對我不起作用。 我可以通過觸摸縮放級別使其工作。 您不會注意到它的發生。

document.getElementById("map_canvas").onclick = function(){
    if(drawingManager.getDrawingMode() !== google.maps.drawing.OverlayType.HAND){
        map2.setZoom(map2.getZoom() + 1);
        map2.setZoom(map2.getZoom() - 1);
    }
};

http://plnkr.co/edit/TP8TIjvdRHHOyg6NKQWc?p=preview

感謝@geocodezip發布解決方法來解決此問題。

解決方法:更改版本

https://maps.googleapis.com/maps/api/js?sensor=false&v=3&libraries=geometry,visualization,drawing

得出:

https://maps.googleapis.com/maps/api/js?sensor=false&v=3.exp&libraries=geometry,visualization,drawing

Plunker修復

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM