From f2ecf5a0a723a9908b892869afcddadf7961ac45 Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Mon, 9 Nov 2015 12:58:30 +0300 Subject: [PATCH] Add routing points layer to the map. --- www/borders.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/www/borders.js b/www/borders.js index 8f27fda..c8c079b 100644 --- a/www/borders.js +++ b/www/borders.js @@ -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 ) {