initial commit

This commit is contained in:
Norbert Renner 2014-01-27 18:34:48 +01:00
parent 37980ff82b
commit 4cc16bccd0
17 changed files with 789 additions and 0 deletions

35
js/plugin/Elevation.js Normal file
View file

@ -0,0 +1,35 @@
BR.Elevation = L.Control.Elevation.extend({
options: {
position: "leftpane",
width: 385,
margins: {
top: 20,
right: 20,
bottom: 30,
left: 50
},
theme: "steelblue-theme" //purple
},
clear: function() {
this._data = [];
this._dist = 0;
this._maxElevation = 0;
// workaround for 'Error: Problem parsing d=""' in Webkit when empty data
// https://groups.google.com/d/msg/d3-js/7rFxpXKXFhI/HzIO_NPeDuMJ
//this._areapath.datum(this._data).attr("d", this._area);
this._areapath.attr("d", "M0 0");
this._x.domain([0,1]);
this._y.domain([0,1]);
this._updateAxis();
},
update: function(track) {
this.clear();
if (track && track.getLatLngs().length > 0) {
this.addData(track);
}
}
});

66
js/plugin/NogoAreas.js Normal file
View file

@ -0,0 +1,66 @@
L.drawLocal.draw.toolbar.buttons.circle = 'Draw no-go area (circle)';
L.drawLocal.edit.toolbar.buttons.edit = 'Edit no-go areas';
L.drawLocal.edit.toolbar.buttons.remove = 'Delete no-go areas';
BR.NogoAreas = L.Control.Draw.extend({
initialize: function () {
this.drawnItems = new L.FeatureGroup();
L.Control.Draw.prototype.initialize.call(this, {
draw: {
position: 'topleft',
polyline: false,
polygon: false,
circle: true,
rectangle: false,
marker: false
},
edit: {
featureGroup: this.drawnItems,
//edit: false,
edit: {
selectedPathOptions: {
//opacity: 0.8
}
},
remove: true
}
});
},
onAdd: function (map) {
map.addLayer(this.drawnItems);
map.on('draw:created', function (e) {
var layer = e.layer;
this.drawnItems.addLayer(layer);
this._fireUpdate();
}, this);
map.on('draw:editstart', function (e) {
this.drawnItems.eachLayer(function (layer) {
layer.on('edit', function(e) {
this._fireUpdate();
}, this);
}, this);
}, this);
map.on('draw:deleted', function (e) {
this._fireUpdate();
}, this);
return L.Control.Draw.prototype.onAdd.call(this, map);
},
getOptions: function() {
return {
nogos: this.drawnItems.getLayers()
};
},
_fireUpdate: function () {
this.fire('update', {options: this.getOptions()});
}
});
BR.NogoAreas.include(L.Mixin.Events);

20
js/plugin/Routing.js Normal file
View file

@ -0,0 +1,20 @@
BR.Routing = L.Routing.extend({
options: {
/* not implemented yet
icons: {
start: new L.Icon.Default({iconUrl: 'bower_components/leaflet-gpx/pin-icon-start.png'}),
end: new L.Icon.Default(),
normal: new L.Icon.Default()
},*/
snapping: null
},
onAdd: function (map) {
var container = L.Routing.prototype.onAdd.call(this, map);
// enable drawing mode
this.draw(true);
return container;
}
});

17
js/plugin/Search.js Normal file
View file

@ -0,0 +1,17 @@
BR.Search = L.Control.Search.extend({
options: {
//url: 'http://nominatim.openstreetmap.org/search?format=json&q={s}',
url: 'http://open.mapquestapi.com/nominatim/v1/search.php?format=json&q={s}',
jsonpParam: 'json_callback',
propertyName: 'display_name',
propertyLoc: ['lat','lon'],
markerLocation: false,
autoType: false,
autoCollapse: true,
minLength: 2,
zoom: 12
},
// patch: interferes with draw plugin (adds all layers twice to map?)
_onLayerAddRemove: function() {}
});