Skip to content

Commit

Permalink
Merge pull request #3 from thegreat/master
Browse files Browse the repository at this point in the history
Leaflet integration
  • Loading branch information
arthur-e committed Oct 10, 2012
2 parents 4b93029 + b351b58 commit 4c69edd
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions wicket-leaflet.src.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
});

0 comments on commit 4c69edd

Please sign in to comment.