wicket-leaflet.src.js
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
Wkt.Wkt.prototype.isRectangle = false;
Wkt.Wkt.prototype.construct = {
point: function (config, component) {
var coord = component || this.components;
if (coord instanceof Array) {
coord = coord[0];
}
return L.marker(this.coordsToLatLng(coord), config);
},
multipoint: function (config) {
var layers = [],
coords = this.components,
latlng;
for (var i = 0, len = coords.length; i < len; i++) {
layers.push(this.construct.point.call(this, config, coords[i]));
}
return L.featureGroup(layers, config);
},
linestring: function (config, component) {
var coords = component || this.components,
latlngs = this.coordsToLatLngs(coords);
return L.polyLine(latlngs);
},
multilinestring: function (config) {
var coords = this.components,
latlngs = this.coordsToLatLngs(coords, 1);
return L.multiPolyline(latlngs);
},
polygon: function (config) {
var coords = this.components,
latlngs = this.coordsToLatLngs(coords, 1);
return L.polygon(latlngs);
},
multipolygon: function (config) {
var coords = this.components,
latlngs = this.coordsToLatLngs(coords, 2);
return L.multiPolygon(latlngs);
}
};
L.Util.extend(Wkt.Wkt.prototype, {
coordsToLatLngs: L.GeoJSON.coordsToLatLngs,
coordsToLatLng: function (coords, reverse) {
var lat = reverse ? coords.x : coords.y,
lng = reverse ? coords.y : coords.x;
return L.latLng(lat, lng, true);
}
});