From d3426d557b659f247b563e974890b07f36914b90 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 12 Dec 2013 15:23:41 -0500 Subject: [PATCH] fix Polygon getBounds and factory --- debug/vector/vector2.html | 13 +++++-------- src/layer/vector2/Polygon.js | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/debug/vector/vector2.html b/debug/vector/vector2.html index 1a718b44..41aa8228 100644 --- a/debug/vector/vector2.html +++ b/debug/vector/vector2.html @@ -21,18 +21,15 @@ latlngs.push(new L.LatLng(route[i][0], route[i][1])); } - var path = new L.Polygon([ - latlngs, - [[50.5, 30.5], [50.5, 40], [40, 40]]]); - var map = new L.Map('map', {layers: [cloudmade]}); - map.fitBounds(new L.LatLngBounds(latlngs)); + map.addLayer(L.marker(latlngs[0])); + map.addLayer(L.marker(latlngs[len - 1])); - map.addLayer(new L.Marker(latlngs[0])); - map.addLayer(new L.Marker(latlngs[len - 1])); + var path = L.polygon([latlngs, [[50.5, 30.5], [50.5, 40], [40, 40]]]).addTo(map); + var poly = L.polyline([[60, 30], [60, 50], [40, 50]], {color: 'red'}).addTo(map); - map.addLayer(path); + map.fitBounds(path); // path.bindPopup("Hello world"); diff --git a/src/layer/vector2/Polygon.js b/src/layer/vector2/Polygon.js index 29f2023c..e4c4d22a 100644 --- a/src/layer/vector2/Polygon.js +++ b/src/layer/vector2/Polygon.js @@ -15,7 +15,7 @@ L.Polygon = L.Polyline.extend({ getBounds: function () { var flat = this._latlngs[0] instanceof L.LatLng; - return flat ? new L.LatLngsBounds(this._latlngs) : this._latlngs[0]; + return new L.LatLngBounds(flat ? this._latlngs : this._latlngs[0]); }, _convertLatLngs: function (latlngs) { @@ -59,5 +59,5 @@ L.Polygon = L.Polyline.extend({ }); L.polygon = function (latlngs, options) { - return new L.Polyline(latlngs, options); + return new L.Polygon(latlngs, options); };