fix Polygon getBounds and factory
This commit is contained in:
parent
d983464ab5
commit
d3426d557b
@ -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");
|
||||
</script>
|
||||
|
@ -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);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user