forked from MTSR/mapserver
border overlay stub
This commit is contained in:
parent
d57be9511c
commit
e67da64e38
@ -47,10 +47,15 @@ var AbstractGeoJsonOverlay = L.LayerGroup.extend({
|
||||
return 7;
|
||||
},
|
||||
|
||||
getMinDisplayedZoom: function(){
|
||||
return 13;
|
||||
},
|
||||
|
||||
reDraw: function(){
|
||||
var self = this;
|
||||
var zoom = this.map.getZoom();
|
||||
|
||||
if (this.map.getZoom() < this.getMaxDisplayedZoom()) {
|
||||
if (zoom < this.getMaxDisplayedZoom() || zoom > this.getMinDisplayedZoom()) {
|
||||
this.clearLayers();
|
||||
return;
|
||||
}
|
||||
|
66
server/static/js/overlays/BorderOverlay.js
Normal file
66
server/static/js/overlays/BorderOverlay.js
Normal file
@ -0,0 +1,66 @@
|
||||
'use strict';
|
||||
|
||||
var BorderOverlay = AbstractGeoJsonOverlay.extend({
|
||||
initialize: function(wsChannel, layerMgr) {
|
||||
AbstractGeoJsonOverlay.prototype.initialize.call(this, wsChannel, layerMgr, "border");
|
||||
},
|
||||
|
||||
createGeoJson: function(objects){
|
||||
var self = this;
|
||||
|
||||
var geoJsonLayer = L.geoJSON([], {
|
||||
onEachFeature: function(feature, layer){
|
||||
if (feature.properties && feature.properties.popupContent) {
|
||||
layer.bindPopup(feature.properties.popupContent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var borders = [];
|
||||
|
||||
objects.forEach(function(obj){
|
||||
if (!obj.attributes.name)
|
||||
return
|
||||
|
||||
var border = borders[obj.attributes.name];
|
||||
if (!border){
|
||||
border = [];
|
||||
borders[obj.attributes.name] = border;
|
||||
}
|
||||
|
||||
border.push(obj);
|
||||
});
|
||||
|
||||
//Order by index and display
|
||||
Object.keys(borders).forEach(function(bordername){
|
||||
borders[bordername].sort(function(a,b){
|
||||
return parseInt(a.attributes.index) - parseInt(b.attributes.index);
|
||||
});
|
||||
|
||||
var coords = [];
|
||||
|
||||
//Add stations
|
||||
borders[bordername].forEach(function(entry){
|
||||
coords.push([entry.x, entry.z]);
|
||||
});
|
||||
|
||||
var feature = {
|
||||
"type":"Feature",
|
||||
"geometry": {
|
||||
"type":"LineString",
|
||||
"coordinates":coords
|
||||
},
|
||||
"properties":{
|
||||
"name": linename,
|
||||
"popupContent": "<b>Border (" + bordername + ")</b>"
|
||||
}
|
||||
}
|
||||
|
||||
//line-points
|
||||
geoJsonLayer.addData(feature);
|
||||
});
|
||||
|
||||
return geoJsonLayer;
|
||||
}
|
||||
|
||||
});
|
@ -18,6 +18,7 @@
|
||||
"/js/overlays/PlayerOverlay.js",
|
||||
"/js/overlays/TrainOverlay.js",
|
||||
"/js/overlays/TrainlineOverlay.js",
|
||||
"/js/overlays/BorderOverlay.js",
|
||||
"/js/overlays/ProtectorOverlay.js",
|
||||
"/js/overlays/XPProtectorOverlay.js",
|
||||
"/js/overlays/PrivProtectorOverlay.js",
|
||||
|
Loading…
Reference in New Issue
Block a user