summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2014-01-10 03:58:56 +0100
committerChristian Franke <nobody@nowhere.ws>2014-01-10 03:59:19 +0100
commitfcf1e574081a01429ef116178b51ad598fe8acab (patch)
tree25bbe818970916d5d10ab31d8baefd0e2d1597e6 /web
parent80fd2820f13861c5cc80d08e4e13a1b238cd4cdf (diff)
Add licence and use osm map
Diffstat (limited to 'web')
-rw-r--r--web/js/eventmap.js134
-rw-r--r--web/js/layers.json10
2 files changed, 86 insertions, 58 deletions
diff --git a/web/js/eventmap.js b/web/js/eventmap.js
index 7302da9..c222005 100644
--- a/web/js/eventmap.js
+++ b/web/js/eventmap.js
@@ -335,65 +335,83 @@ $(function() {
});
$("#progress").html("Retrieving layer info...");
- $.getJSON('js/layers.json', function(data) {
- $("#progress").html("Creating layers...");
- var first_layer = true;
- $.each(data, function(layer_index, layer_info) {
- var layer_path;
- var base_layer;
- var drawing_layer;
- var layer;
-
- layer_path = 'images/tiles/' + layer_info.name
- + '/{z}/{x}/{y}.png';
-
- base_layer = L.tileLayer(layer_path, {
- noWrap: true,
- continuousWorld: true,
- maxZoom: layer_info.max_zoom
- });
-
- drawing_layer = new L.FeatureGroup();
-
- layer = L.layerGroup([base_layer, drawing_layer]);
- layers[layer_info.name] = layer;
-
- if (first_layer) {
- map.addLayer(layer);
- first_layer = false;
- }
- });
- var layer_control = L.control.layers(layers, {});
- map.on('baselayerchange', function() {
- if (search_control._markerLoc !== undefined)
- search_control._markerLoc.hide();
- });
- layer_control.addTo(map);
-
- $("#progress").html("Loading marker info...");
- $.ajax({
- url: 'api/markers/get'
- }).done(function(data) {
- $("#progress").html("Processing marker info...");
- try {
- eventmap_process_update(data);
- } catch (e) {
- if (e instanceof LoadingException) {
- $("#progress").html("Error: " + e.message);
+ $.ajax({
+ url: "js/layers.json",
+ success: function(data) {
+ $("#progress").html("Creating layers...");
+ var first_layer = true;
+ $.each(data, function(layer_index, layer_info) {
+ var layer_path;
+ var layer_options;
+ var base_layer;
+ var drawing_layer;
+ var layer;
+
+ if (layer_info.url === undefined) {
+ layer_path = 'images/tiles/' + layer_info.name
+ + '/{z}/{x}/{y}.png';
} else {
- $("#progress").html("Unknown error while "
- + "loading marker info.");
- throw e;
+ layer_path = layer_info.url;
}
- return;
- }
- $("#progress").html("Loading complete.");
- setTimeout(function() {
- $("#overlay").hide();
- }, 300);
- }).fail(function() {
- $("#progress").html("Error retrieving marker info," +
- " please retry.");
- });
+
+ if (layer_info.options === undefined) {
+ layer_options = {
+ noWrap: true,
+ continuousWorld: true,
+ maxZoom: layer_info.max_zoom
+ };
+ } else {
+ layer_options = layer_info.options;
+ }
+
+ base_layer = L.tileLayer(layer_path, layer_options);
+
+ drawing_layer = new L.FeatureGroup();
+
+ layer = L.layerGroup([base_layer, drawing_layer]);
+ layers[layer_info.name] = layer;
+
+ if (first_layer) {
+ map.addLayer(layer);
+ first_layer = false;
+ }
+ });
+ var layer_control = L.control.layers(layers, {});
+ map.on('baselayerchange', function() {
+ if (search_control._markerLoc !== undefined)
+ search_control._markerLoc.hide();
+ });
+ layer_control.addTo(map);
+
+ $("#progress").html("Loading marker info...");
+ $.ajax({
+ url: 'api/markers/get'
+ }).done(function(data) {
+ $("#progress").html("Processing marker info...");
+ try {
+ eventmap_process_update(data);
+ } catch (e) {
+ if (e instanceof LoadingException) {
+ $("#progress").html("Error: " + e.message);
+ } else {
+ $("#progress").html("Unknown error while "
+ + "loading marker info.");
+ throw e;
+ }
+ return;
+ }
+ $("#progress").html("Loading complete.");
+ setTimeout(function() {
+ $("#overlay").hide();
+ }, 300);
+ }).fail(function() {
+ $("#progress").html("Error retrieving marker info," +
+ " please retry.");
+ });
+ },
+ error: function(xhr, status_text, error) {
+ console.log(status_text);
+ console.log(error);
+ }
});
});
diff --git a/web/js/layers.json b/web/js/layers.json
new file mode 100644
index 0000000..3ea038a
--- /dev/null
+++ b/web/js/layers.json
@@ -0,0 +1,10 @@
+[
+ {
+ "url": "http://{s}.tile.osm.org/{z}/{x}/{y}.png",
+ "max_zoom": 4,
+ "name": "OSM",
+ "options": {
+ "attribution": "&copy; <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors"
+ }
+ }
+]