Add routing points layer to the map.

This commit is contained in:
Lev Dragunov 2015-11-09 12:58:30 +03:00
parent 15614a7018
commit f2ecf5a0a7

View file

@ -10,6 +10,7 @@ var map, borders = {}, bordersLayer, selectedId, editing = false, readonly = fal
var size_good = 5, size_bad = 50;
var tooSmallLayer = null;
var oldBordersLayer = null;
var routingGroup = null;
function init() {
map = L.map('map', { editable: true }).setView([30, 0], 3);
@ -19,6 +20,7 @@ function init() {
{ attribution: '© GIScience Heidelberg' }).addTo(map);
bordersLayer = L.layerGroup();
map.addLayer(bordersLayer);
routingGroup = new L.FeatureGroup();
map.on('moveend', function() {
if( map.getZoom() >= 5 )
@ -89,6 +91,18 @@ function updateBorders() {
simplified: simplified
});
$.ajax(getServer('routing'), {
data: {
'xmin': b.getWest(),
'xmax': b.getEast(),
'ymin': b.getSouth(),
'ymax': b.getNorth()
},
success: processRouting,
dataType: 'json',
simplified: simplified
});
if( oldBordersLayer != null && OLD_BORDERS_NAME ) {
oldBordersLayer.clearLayers();
$.ajax(getServer('bbox'), {
@ -106,6 +120,22 @@ function updateBorders() {
}
}
routingTypes = {1: "Border and feature are intersecting several times.",
2: "Unknown outgoing feature."};
function processRouting(data) {
routingGroup.clearLayers();
map.removeLayer(routingGroup);
for( var f = 0; f < data.features.length; f++ ) {
marker = L.marker([data.features[f]["lon"], data.features[f]["lat"]]).addTo(map);
marker.bindPopup(routingTypes[data.features[f]["type"]], {
showOnMouseOver: true
});
routingGroup.addLayer(marker);
}
map.addLayer(routingGroup);
}
function processResult(data) {
for( var id in borders ) {
if( id != selectedId || !editing ) {