2017-04-24 14 views
1

getBounds()とcontains()をCircleシェイプで実行しようとすると、以下のエラーが表示されます。Circle getBounds()とcontains()を使用するとエラーが発生する

leaflet.js:7 Uncaught TypeError: Cannot read property 'layerPointToLatLng' of undefined 

他の形でも使用できますが、円は頑固です。私はこれを試しましたsolution別の質問から、しかし成功しません。

ここでは、多角形や四角形形状のために私が持っているコードです:

drawnLayers.eachLayer(function(l) { 
    if (type == 'circle') { 

    // console.log(l.getBounds().contains(layer.getBounds())); 

    } else { 
    if (l.getBounds().contains(layer.getBounds())) { 
     isDonut = true; 

     l._latlngs.push(layer.getLatLngs()); 
     l.redraw(); 

     $('#map-info').append("<br>New Polygon: <pre>" + 
     JSON.stringify(l.getLatLngs(), null, 2) + '</pre>'); 
    } 
    } 
}); 
+0

https://github.com/Leaflet/Leaflet/issues/4978を参照してください – IvanSanchez

答えて

0
l.getBounds().contains(layer.getBounds()) 

getBounds()は、それを添加したリーフレット0.7.xでのみpolyline/polygon/rectangleへの具体的な方法

ですバージョン1.0.0の円を描く - leaflet reference versions

問題を解決するには2 o形状は、あなたのリーフレットライブラリアップグレードあなたの他の形状

  • が含まれている場合ptions

    1. 使用getRadius()のような円のためのいくつかの他の方法とは

    は個人的に私は1.0.3にリーフレットライブラリをアップグレードするだろう、自分で計算します(私は非常に簡単で、私のプロジェクトでは互換性の問題なし)

  • 関連する問題