Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
$(window).on('entity:map', function (e, data) { | ||
|
||
var map = data.map; | ||
var loaded_district = false; | ||
var loaded_city = false; | ||
|
||
// Add land layers | ||
var landLayers = [{url: window.SETTINGS.urls.district_layer, name: tr("Districts"), id: 'district'}, | ||
{url: window.SETTINGS.urls.city_layer, name: tr("Cities"), id: 'city'}]; | ||
|
||
landLayers = landLayers.concat(window.SETTINGS.map['restricted_area_types']); | ||
|
||
for (var i=0; i<landLayers.length; i++) { | ||
var landLayer = landLayers[i]; | ||
$.each([[tr("Districts"), 'district'], [tr("Cities"), 'city']], function (i, modelname, name) { | ||
var style = L.Util.extend({clickable: false}, | ||
window.SETTINGS.map.styles[landLayer.id] || {}); | ||
|
||
var colorspools = L.Util.extend({}, window.SETTINGS.map.colorspool), | ||
colorspool = colorspools[landLayer.id]; | ||
if (colorspool) { | ||
var color = colorspool[i % colorspool.length]; | ||
style['color'] = color; | ||
} | ||
|
||
window.SETTINGS.map.styles[modelname[1]] || {}); | ||
var nameHTML = '<span style="color: '+ style['color'] + ';">⬤</span> ' + modelname[0]; | ||
var layer = new L.ObjectsLayer(null, { | ||
indexing: false, | ||
style: style, | ||
modelname: landLayer.id, | ||
indexing: false, | ||
modelname: modelname[1], | ||
style: style, | ||
}); | ||
layer.load(landLayer.url); | ||
|
||
var nameHTML = '<span style="color: '+ style['color'] + ';">⬤</span> ' + landLayer.name; | ||
map.layerscontrol.addOverlay(layer, nameHTML, tr('Zoning')); | ||
} | ||
|
||
map.on('layeradd', function(e){ | ||
var options = e.layer.options || {'modelname': 'None'}; | ||
if (! loaded_district){ | ||
if (options.modelname == 'district'){ | ||
e.layer.load(window.SETTINGS.urls.district_layer); | ||
loaded_district = true; | ||
} | ||
} | ||
if (! loaded_city){ | ||
if (options.modelname == 'city'){ | ||
e.layer.load(window.SETTINGS.urls.city_layer); | ||
loaded_city = true; | ||
} | ||
} | ||
}); | ||
}); | ||
}); |