1
0
forked from MTSR/mapserver

border overlay stub

This commit is contained in:
NatureFreshMilk 2019-04-04 08:45:42 +02:00
parent d57be9511c
commit e67da64e38
3 changed files with 73 additions and 1 deletions

View File

@ -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;
}

View 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;
}
});

View File

@ -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",