Use double quotes consistently in javascript code
This commit is contained in:
parent
87127d41e9
commit
eb7678145a
29 changed files with 650 additions and 649 deletions
|
@ -17,7 +17,7 @@
|
||||||
//= require richtext
|
//= require richtext
|
||||||
//= require querystring
|
//= require querystring
|
||||||
|
|
||||||
var querystring = require('querystring-component');
|
var querystring = require("querystring-component");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called as the user scrolls/zooms around to maniplate hrefs of the
|
* Called as the user scrolls/zooms around to maniplate hrefs of the
|
||||||
|
@ -39,11 +39,11 @@ window.updateLinks = function (loc, zoom, layers, object) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var query = querystring.stringify(args);
|
var query = querystring.stringify(args);
|
||||||
if (query) href += '?' + query;
|
if (query) href += "?" + query;
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
lat: loc.lat,
|
lat: loc.lat,
|
||||||
lon: 'lon' in loc ? loc.lon : loc.lng,
|
lon: "lon" in loc ? loc.lon : loc.lng,
|
||||||
zoom: zoom
|
zoom: zoom
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,13 +57,13 @@ window.updateLinks = function (loc, zoom, layers, object) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var editDisabled = zoom < 13;
|
var editDisabled = zoom < 13;
|
||||||
$('#edit_tab')
|
$("#edit_tab")
|
||||||
.tooltip({placement: 'bottom'})
|
.tooltip({placement: "bottom"})
|
||||||
.off('click.minzoom')
|
.off("click.minzoom")
|
||||||
.on('click.minzoom', function() { return !editDisabled; })
|
.on("click.minzoom", function() { return !editDisabled; })
|
||||||
.toggleClass('disabled', editDisabled)
|
.toggleClass("disabled", editDisabled)
|
||||||
.attr('data-original-title', editDisabled ?
|
.attr("data-original-title", editDisabled ?
|
||||||
I18n.t('javascripts.site.edit_disabled_tooltip') : '');
|
I18n.t("javascripts.site.edit_disabled_tooltip") : "");
|
||||||
};
|
};
|
||||||
|
|
||||||
window.maximiseMap = function () {
|
window.maximiseMap = function () {
|
||||||
|
|
|
@ -10,7 +10,7 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
marker = L.marker(e.latlng, {icon: OSM.getUserIcon()}).addTo(map)
|
marker = L.marker(e.latlng, {icon: OSM.getUserIcon()}).addTo(map)
|
||||||
.bindPopup(I18n.t('diary_entries.edit.marker_text'));
|
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#usemap").click(function (e) {
|
$("#usemap").click(function (e) {
|
||||||
|
@ -21,7 +21,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
var params = $("#map").data();
|
var params = $("#map").data();
|
||||||
var centre = [params.lat, params.lon];
|
var centre = [params.lat, params.lon];
|
||||||
var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
|
var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
|
||||||
|
|
||||||
map = L.map("map", {
|
map = L.map("map", {
|
||||||
attributionControl: false,
|
attributionControl: false,
|
||||||
|
@ -35,7 +35,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
if ($("#latitude").val() && $("#longitude").val()) {
|
if ($("#latitude").val() && $("#longitude").val()) {
|
||||||
marker = L.marker(centre, {icon: OSM.getUserIcon()}).addTo(map)
|
marker = L.marker(centre, {icon: OSM.getUserIcon()}).addTo(map)
|
||||||
.bindPopup(I18n.t('diary_entries.edit.marker_text'));
|
.bindPopup(I18n.t("diary_entries.edit.marker_text"));
|
||||||
}
|
}
|
||||||
|
|
||||||
map.on("click", setLocation);
|
map.on("click", setLocation);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var params = OSM.params();
|
var params = OSM.params();
|
||||||
|
|
||||||
var url = '/note/new';
|
var url = "/note/new";
|
||||||
if (params.lat && params.lon) {
|
if (params.lat && params.lon) {
|
||||||
params.lat = parseFloat(params.lat);
|
params.lat = parseFloat(params.lat);
|
||||||
params.lon = parseFloat(params.lon);
|
params.lon = parseFloat(params.lon);
|
||||||
params.zoom = params.zoom || 17;
|
params.zoom = params.zoom || 17;
|
||||||
url += OSM.formatHash(params);
|
url += OSM.formatHash(params);
|
||||||
}
|
}
|
||||||
$('.icon.note').attr('href', url);
|
$(".icon.note").attr("href", url);
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
var container = document.getElementById("id-container");
|
var container = document.getElementById("id-container");
|
||||||
|
|
||||||
if (typeof iD === 'undefined' || !iD.Detect().support) {
|
if (typeof iD === "undefined" || !iD.Detect().support) {
|
||||||
container.innerHTML = 'This editor is supported ' +
|
container.innerHTML = "This editor is supported " +
|
||||||
'in Firefox, Chrome, Safari, Opera, Edge, and Internet Explorer 11. ' +
|
"in Firefox, Chrome, Safari, Opera, Edge, and Internet Explorer 11. " +
|
||||||
'Please upgrade your browser or use Potlatch 2 to edit the map.';
|
"Please upgrade your browser or use Potlatch 2 to edit the map.";
|
||||||
container.className = 'unsupported';
|
container.className = "unsupported";
|
||||||
} else {
|
} else {
|
||||||
var id = iD.Context()
|
var id = iD.Context()
|
||||||
.embed(true)
|
.embed(true)
|
||||||
|
@ -24,7 +24,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
||||||
oauth_token_secret: container.dataset.tokenSecret
|
oauth_token_secret: container.dataset.tokenSecret
|
||||||
});
|
});
|
||||||
|
|
||||||
id.map().on('move.embed', parent.$.throttle(250, function() {
|
id.map().on("move.embed", parent.$.throttle(250, function() {
|
||||||
if (id.inIntro()) return;
|
if (id.inIntro()) return;
|
||||||
var zoom = ~~id.map().zoom(),
|
var zoom = ~~id.map().zoom(),
|
||||||
center = id.map().center(),
|
center = id.map().center(),
|
||||||
|
|
|
@ -37,18 +37,18 @@ $(document).ready(function () {
|
||||||
clearTimeout(loaderTimeout);
|
clearTimeout(loaderTimeout);
|
||||||
|
|
||||||
loaderTimeout = setTimeout(function() {
|
loaderTimeout = setTimeout(function() {
|
||||||
$('#sidebar_loader').show();
|
$("#sidebar_loader").show();
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
// IE<10 doesn't respect Vary: X-Requested-With header, so
|
// IE<10 doesn't respect Vary: X-Requested-With header, so
|
||||||
// prevent caching the XHR response as a full-page URL.
|
// prevent caching the XHR response as a full-page URL.
|
||||||
if (path.indexOf('?') >= 0) {
|
if (path.indexOf("?") >= 0) {
|
||||||
path += '&xhr=1';
|
path += "&xhr=1";
|
||||||
} else {
|
} else {
|
||||||
path += '?xhr=1';
|
path += "?xhr=1";
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#sidebar_content')
|
$("#sidebar_content")
|
||||||
.empty();
|
.empty();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -56,24 +56,24 @@ $(document).ready(function () {
|
||||||
dataType: "html",
|
dataType: "html",
|
||||||
complete: function(xhr) {
|
complete: function(xhr) {
|
||||||
clearTimeout(loaderTimeout);
|
clearTimeout(loaderTimeout);
|
||||||
$('#flash').empty();
|
$("#flash").empty();
|
||||||
$('#sidebar_loader').hide();
|
$("#sidebar_loader").hide();
|
||||||
|
|
||||||
var content = $(xhr.responseText);
|
var content = $(xhr.responseText);
|
||||||
|
|
||||||
if (xhr.getResponseHeader('X-Page-Title')) {
|
if (xhr.getResponseHeader("X-Page-Title")) {
|
||||||
var title = xhr.getResponseHeader('X-Page-Title');
|
var title = xhr.getResponseHeader("X-Page-Title");
|
||||||
document.title = decodeURIComponent(title);
|
document.title = decodeURIComponent(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('head')
|
$("head")
|
||||||
.find('link[type="application/atom+xml"]')
|
.find("link[type=\"application/atom+xml\"]")
|
||||||
.remove();
|
.remove();
|
||||||
|
|
||||||
$('head')
|
$("head")
|
||||||
.append(content.filter('link[type="application/atom+xml"]'));
|
.append(content.filter("link[type=\"application/atom+xml\"]"));
|
||||||
|
|
||||||
$('#sidebar_content').html(content.not('link[type="application/atom+xml"]'));
|
$("#sidebar_content").html(content.not("link[type=\"application/atom+xml\"]"));
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
|
@ -84,7 +84,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
var params = OSM.mapParams();
|
var params = OSM.mapParams();
|
||||||
|
|
||||||
map.attributionControl.setPrefix('');
|
map.attributionControl.setPrefix("");
|
||||||
|
|
||||||
map.updateLayers(params.layers);
|
map.updateLayers(params.layers);
|
||||||
|
|
||||||
|
@ -94,32 +94,32 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
|
var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
|
||||||
|
|
||||||
L.OSM.zoom({position: position})
|
L.OSM.zoom({position: position})
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
var locate = L.control.locate({
|
var locate = L.control.locate({
|
||||||
position: position,
|
position: position,
|
||||||
icon: 'icon geolocate',
|
icon: "icon geolocate",
|
||||||
iconLoading: 'icon geolocate',
|
iconLoading: "icon geolocate",
|
||||||
strings: {
|
strings: {
|
||||||
title: I18n.t('javascripts.map.locate.title'),
|
title: I18n.t("javascripts.map.locate.title"),
|
||||||
popup: I18n.t('javascripts.map.locate.popup')
|
popup: I18n.t("javascripts.map.locate.popup")
|
||||||
}
|
}
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
var locateContainer = locate.getContainer();
|
var locateContainer = locate.getContainer();
|
||||||
|
|
||||||
$(locateContainer)
|
$(locateContainer)
|
||||||
.removeClass('leaflet-control-locate leaflet-bar')
|
.removeClass("leaflet-control-locate leaflet-bar")
|
||||||
.addClass('control-locate')
|
.addClass("control-locate")
|
||||||
.children("a")
|
.children("a")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.removeClass('leaflet-bar-part leaflet-bar-part-single')
|
.removeClass("leaflet-bar-part leaflet-bar-part-single")
|
||||||
.addClass('control-button');
|
.addClass("control-button");
|
||||||
|
|
||||||
var sidebar = L.OSM.sidebar('#map-ui')
|
var sidebar = L.OSM.sidebar("#map-ui")
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
L.OSM.layers({
|
L.OSM.layers({
|
||||||
|
@ -154,7 +154,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
OSM.initializeContextMenu(map);
|
OSM.initializeContextMenu(map);
|
||||||
|
|
||||||
if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
|
if (OSM.STATUS !== "api_offline" && OSM.STATUS !== "database_offline") {
|
||||||
OSM.initializeNotes(map);
|
OSM.initializeNotes(map);
|
||||||
if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
|
if (params.layers.indexOf(map.noteLayer.options.code) >= 0) {
|
||||||
map.addLayer(map.noteLayer);
|
map.addLayer(map.noteLayer);
|
||||||
|
@ -170,51 +170,51 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var placement = $('html').attr('dir') === 'rtl' ? 'right' : 'left';
|
var placement = $("html").attr("dir") === "rtl" ? "right" : "left";
|
||||||
$('.leaflet-control .control-button').tooltip({placement: placement, container: 'body'});
|
$(".leaflet-control .control-button").tooltip({placement: placement, container: "body"});
|
||||||
|
|
||||||
var expiry = new Date();
|
var expiry = new Date();
|
||||||
expiry.setYear(expiry.getFullYear() + 10);
|
expiry.setYear(expiry.getFullYear() + 10);
|
||||||
|
|
||||||
map.on('moveend layeradd layerremove', function() {
|
map.on("moveend layeradd layerremove", function() {
|
||||||
updateLinks(
|
updateLinks(
|
||||||
map.getCenter().wrap(),
|
map.getCenter().wrap(),
|
||||||
map.getZoom(),
|
map.getZoom(),
|
||||||
map.getLayersCode(),
|
map.getLayersCode(),
|
||||||
map._object);
|
map._object);
|
||||||
|
|
||||||
$.removeCookie('_osm_location');
|
$.removeCookie("_osm_location");
|
||||||
$.cookie('_osm_location', OSM.locationCookie(map), { expires: expiry, path: '/' });
|
$.cookie("_osm_location", OSM.locationCookie(map), { expires: expiry, path: "/" });
|
||||||
});
|
});
|
||||||
|
|
||||||
if ($.cookie('_osm_welcome') !== 'hide') {
|
if ($.cookie("_osm_welcome") !== "hide") {
|
||||||
$('.welcome').addClass('visible');
|
$(".welcome").addClass("visible");
|
||||||
}
|
}
|
||||||
|
|
||||||
$('.welcome .close-wrap').on('click', function() {
|
$(".welcome .close-wrap").on("click", function() {
|
||||||
$('.welcome').removeClass('visible');
|
$(".welcome").removeClass("visible");
|
||||||
$.cookie('_osm_welcome', 'hide', { expires: expiry, path: '/' });
|
$.cookie("_osm_welcome", "hide", { expires: expiry, path: "/" });
|
||||||
});
|
});
|
||||||
|
|
||||||
var bannerExpiry = new Date();
|
var bannerExpiry = new Date();
|
||||||
bannerExpiry.setYear(bannerExpiry.getFullYear() + 1);
|
bannerExpiry.setYear(bannerExpiry.getFullYear() + 1);
|
||||||
|
|
||||||
$('#banner .close-wrap').on('click', function(e) {
|
$("#banner .close-wrap").on("click", function(e) {
|
||||||
var cookieId = e.target.id;
|
var cookieId = e.target.id;
|
||||||
$('#banner').hide();
|
$("#banner").hide();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (cookieId) {
|
if (cookieId) {
|
||||||
$.cookie(cookieId, 'hide', { expires: bannerExpiry, path: '/' });
|
$.cookie(cookieId, "hide", { expires: bannerExpiry, path: "/" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (OSM.PIWIK) {
|
if (OSM.PIWIK) {
|
||||||
map.on('layeradd', function (e) {
|
map.on("layeradd", function (e) {
|
||||||
if (e.layer.options) {
|
if (e.layer.options) {
|
||||||
var goal = OSM.PIWIK.goals[e.layer.options.keyid];
|
var goal = OSM.PIWIK.goals[e.layer.options.keyid];
|
||||||
|
|
||||||
if (goal) {
|
if (goal) {
|
||||||
$('body').trigger('piwikgoal', goal);
|
$("body").trigger("piwikgoal", goal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -250,7 +250,7 @@ $(document).ready(function () {
|
||||||
bottom: bbox.getSouth() - 0.0001
|
bottom: bbox.getSouth() - 0.0001
|
||||||
};
|
};
|
||||||
|
|
||||||
if (location.protocol === 'http' ||
|
if (location.protocol === "http" ||
|
||||||
bowser.check({chrome: "53", firefox: "55"})) {
|
bowser.check({chrome: "53", firefox: "55"})) {
|
||||||
url = "http://127.0.0.1:8111/load_and_zoom?";
|
url = "http://127.0.0.1:8111/load_and_zoom?";
|
||||||
} else {
|
} else {
|
||||||
|
@ -259,18 +259,18 @@ $(document).ready(function () {
|
||||||
|
|
||||||
if (object) query.select = object.type + object.id;
|
if (object) query.select = object.type + object.id;
|
||||||
|
|
||||||
var iframe = $('<iframe>')
|
var iframe = $("<iframe>")
|
||||||
.hide()
|
.hide()
|
||||||
.appendTo('body')
|
.appendTo("body")
|
||||||
.attr("src", url + querystring.stringify(query))
|
.attr("src", url + querystring.stringify(query))
|
||||||
.on('load', function() {
|
.on("load", function() {
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
loaded = true;
|
loaded = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
alert(I18n.t('site.index.remote_failed'));
|
alert(I18n.t("site.index.remote_failed"));
|
||||||
iframe.remove();
|
iframe.remove();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
@ -285,16 +285,16 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (OSM.params().edit_help) {
|
if (OSM.params().edit_help) {
|
||||||
$('#editanchor')
|
$("#editanchor")
|
||||||
.removeAttr('title')
|
.removeAttr("title")
|
||||||
.tooltip({
|
.tooltip({
|
||||||
placement: 'bottom',
|
placement: "bottom",
|
||||||
title: I18n.t('javascripts.edit_help')
|
title: I18n.t("javascripts.edit_help")
|
||||||
})
|
})
|
||||||
.tooltip('show');
|
.tooltip("show");
|
||||||
|
|
||||||
$('body').one('click', function() {
|
$("body").one("click", function() {
|
||||||
$('#editanchor').tooltip('hide');
|
$("#editanchor").tooltip("hide");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
page.pushstate = page.popstate = function() {
|
page.pushstate = page.popstate = function() {
|
||||||
map.setSidebarOverlaid(true);
|
map.setSidebarOverlaid(true);
|
||||||
document.title = I18n.t('layouts.project_name.title');
|
document.title = I18n.t("layouts.project_name.title");
|
||||||
};
|
};
|
||||||
|
|
||||||
page.load = function() {
|
page.load = function() {
|
||||||
|
@ -364,9 +364,9 @@ $(document).ready(function () {
|
||||||
"/history": history,
|
"/history": history,
|
||||||
"/user/:display_name/history": history,
|
"/user/:display_name/history": history,
|
||||||
"/note/:id": OSM.Note(map),
|
"/note/:id": OSM.Note(map),
|
||||||
"/node/:id(/history)": OSM.Browse(map, 'node'),
|
"/node/:id(/history)": OSM.Browse(map, "node"),
|
||||||
"/way/:id(/history)": OSM.Browse(map, 'way'),
|
"/way/:id(/history)": OSM.Browse(map, "way"),
|
||||||
"/relation/:id(/history)": OSM.Browse(map, 'relation'),
|
"/relation/:id(/history)": OSM.Browse(map, "relation"),
|
||||||
"/changeset/:id": OSM.Changeset(map),
|
"/changeset/:id": OSM.Changeset(map),
|
||||||
"/query": OSM.Query(map)
|
"/query": OSM.Query(map)
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,17 +26,17 @@ OSM.initializeBrowse = function (map) {
|
||||||
onSelect(e.layer);
|
onSelect(e.layer);
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('layeradd', function (e) {
|
map.on("layeradd", function (e) {
|
||||||
if (e.layer === dataLayer) {
|
if (e.layer === dataLayer) {
|
||||||
map.on("moveend", updateData);
|
map.on("moveend", updateData);
|
||||||
updateData();
|
updateData();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('layerremove', function (e) {
|
map.on("layerremove", function (e) {
|
||||||
if (e.layer === dataLayer) {
|
if (e.layer === dataLayer) {
|
||||||
map.off("moveend", updateData);
|
map.off("moveend", updateData);
|
||||||
$('#browse_status').empty();
|
$("#browse_status").empty();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ OSM.initializeBrowse = function (map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayFeatureWarning(count, limit, add, cancel) {
|
function displayFeatureWarning(count, limit, add, cancel) {
|
||||||
$('#browse_status').html(
|
$("#browse_status").html(
|
||||||
$("<p class='warning'></p>")
|
$("<p class='warning'></p>")
|
||||||
.text(I18n.t("browse.start_rjs.feature_warning", { num_features: count, max_features: limit }))
|
.text(I18n.t("browse.start_rjs.feature_warning", { num_features: count, max_features: limit }))
|
||||||
.prepend(
|
.prepend(
|
||||||
|
@ -56,7 +56,7 @@ OSM.initializeBrowse = function (map) {
|
||||||
.click(cancel))
|
.click(cancel))
|
||||||
.append(
|
.append(
|
||||||
$("<input type='submit'>")
|
$("<input type='submit'>")
|
||||||
.val(I18n.t('browse.start_rjs.load_data'))
|
.val(I18n.t("browse.start_rjs.load_data"))
|
||||||
.click(add)));
|
.click(add)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,13 +92,13 @@ OSM.initializeBrowse = function (map) {
|
||||||
var features = dataLayer.buildFeatures(xml);
|
var features = dataLayer.buildFeatures(xml);
|
||||||
|
|
||||||
function addFeatures() {
|
function addFeatures() {
|
||||||
$('#browse_status').empty();
|
$("#browse_status").empty();
|
||||||
dataLayer.addData(features);
|
dataLayer.addData(features);
|
||||||
browseBounds = bounds;
|
browseBounds = bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelAddFeatures() {
|
function cancelAddFeatures() {
|
||||||
$('#browse_status').empty();
|
$("#browse_status").empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (features.length < maxFeatures) {
|
if (features.length < maxFeatures) {
|
||||||
|
@ -120,9 +120,9 @@ OSM.initializeBrowse = function (map) {
|
||||||
|
|
||||||
// Redraw in selected style
|
// Redraw in selected style
|
||||||
layer.originalStyle = layer.options;
|
layer.originalStyle = layer.options;
|
||||||
layer.setStyle({color: '#0000ff', weight: 8});
|
layer.setStyle({color: "#0000ff", weight: 8});
|
||||||
|
|
||||||
OSM.router.route('/' + layer.feature.type + '/' + layer.feature.id);
|
OSM.router.route("/" + layer.feature.type + "/" + layer.feature.id);
|
||||||
|
|
||||||
// Stash the currently drawn feature
|
// Stash the currently drawn feature
|
||||||
selectedLayer = layer;
|
selectedLayer = layer;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
OSM.Changeset = function (map) {
|
OSM.Changeset = function (map) {
|
||||||
var page = {},
|
var page = {},
|
||||||
content = $('#sidebar_content'),
|
content = $("#sidebar_content"),
|
||||||
currentChangesetId;
|
currentChangesetId;
|
||||||
|
|
||||||
page.pushstate = page.popstate = function(path, id) {
|
page.pushstate = page.popstate = function(path, id) {
|
||||||
|
@ -17,7 +17,7 @@ OSM.Changeset = function (map) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function addChangeset(id, center) {
|
function addChangeset(id, center) {
|
||||||
map.addObject({type: 'changeset', id: parseInt(id, 10)}, function(bounds) {
|
map.addObject({type: "changeset", id: parseInt(id, 10)}, function(bounds) {
|
||||||
if (!window.location.hash && bounds.isValid() &&
|
if (!window.location.hash && bounds.isValid() &&
|
||||||
(center || !map.getBounds().contains(bounds))) {
|
(center || !map.getBounds().contains(bounds))) {
|
||||||
OSM.router.withoutMoveListener(function () {
|
OSM.router.withoutMoveListener(function () {
|
||||||
|
@ -72,7 +72,7 @@ OSM.Changeset = function (map) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
content.find("textarea").val('').trigger("input");
|
content.find("textarea").val("").trigger("input");
|
||||||
}
|
}
|
||||||
|
|
||||||
page.unload = function() {
|
page.unload = function() {
|
||||||
|
|
|
@ -9,13 +9,13 @@ OSM.Directions = function (map) {
|
||||||
var popup = L.popup({autoPanPadding: [100, 100]});
|
var popup = L.popup({autoPanPadding: [100, 100]});
|
||||||
|
|
||||||
var polyline = L.polyline([], {
|
var polyline = L.polyline([], {
|
||||||
color: '#03f',
|
color: "#03f",
|
||||||
opacity: 0.3,
|
opacity: 0.3,
|
||||||
weight: 10
|
weight: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
var highlight = L.polyline([], {
|
var highlight = L.polyline([], {
|
||||||
color: '#ff0',
|
color: "#ff0",
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
weight: 12
|
weight: 12
|
||||||
});
|
});
|
||||||
|
@ -31,15 +31,15 @@ OSM.Directions = function (map) {
|
||||||
var engines = OSM.Directions.engines;
|
var engines = OSM.Directions.engines;
|
||||||
|
|
||||||
engines.sort(function (a, b) {
|
engines.sort(function (a, b) {
|
||||||
a = I18n.t('javascripts.directions.engines.' + a.id);
|
a = I18n.t("javascripts.directions.engines." + a.id);
|
||||||
b = I18n.t('javascripts.directions.engines.' + b.id);
|
b = I18n.t("javascripts.directions.engines." + b.id);
|
||||||
return a.localeCompare(b);
|
return a.localeCompare(b);
|
||||||
});
|
});
|
||||||
|
|
||||||
var select = $('select.routing_engines');
|
var select = $("select.routing_engines");
|
||||||
|
|
||||||
engines.forEach(function(engine, i) {
|
engines.forEach(function(engine, i) {
|
||||||
select.append("<option value='" + i + "'>" + I18n.t('javascripts.directions.engines.' + engine.id) + "</option>");
|
select.append("<option value='" + i + "'>" + I18n.t("javascripts.directions.engines." + engine.id) + "</option>");
|
||||||
});
|
});
|
||||||
|
|
||||||
function Endpoint(input, iconUrl) {
|
function Endpoint(input, iconUrl) {
|
||||||
|
@ -58,8 +58,8 @@ OSM.Directions = function (map) {
|
||||||
autoPan: true
|
autoPan: true
|
||||||
});
|
});
|
||||||
|
|
||||||
endpoint.marker.on('drag dragend', function (e) {
|
endpoint.marker.on("drag dragend", function (e) {
|
||||||
var dragging = (e.type === 'drag');
|
var dragging = (e.type === "drag");
|
||||||
if (dragging && !chosenEngine.draggable) return;
|
if (dragging && !chosenEngine.draggable) return;
|
||||||
if (dragging && awaitingRoute) return;
|
if (dragging && awaitingRoute) return;
|
||||||
endpoint.setLatLng(e.target.getLatLng());
|
endpoint.setLatLng(e.target.getLatLng());
|
||||||
|
@ -102,12 +102,12 @@ OSM.Directions = function (map) {
|
||||||
|
|
||||||
endpoint.awaitingGeocode = true;
|
endpoint.awaitingGeocode = true;
|
||||||
|
|
||||||
$.getJSON(OSM.NOMINATIM_URL + 'search?q=' + encodeURIComponent(endpoint.value) + '&format=json', function (json) {
|
$.getJSON(OSM.NOMINATIM_URL + "search?q=" + encodeURIComponent(endpoint.value) + "&format=json", function (json) {
|
||||||
endpoint.awaitingGeocode = false;
|
endpoint.awaitingGeocode = false;
|
||||||
endpoint.hasGeocode = true;
|
endpoint.hasGeocode = true;
|
||||||
if (json.length === 0) {
|
if (json.length === 0) {
|
||||||
input.addClass("error");
|
input.addClass("error");
|
||||||
alert(I18n.t('javascripts.directions.errors.no_place', {place: endpoint.value}));
|
alert(I18n.t("javascripts.directions.errors.no_place", {place: endpoint.value}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ OSM.Directions = function (map) {
|
||||||
var m = Math.round(s / 60);
|
var m = Math.round(s / 60);
|
||||||
var h = Math.floor(m / 60);
|
var h = Math.floor(m / 60);
|
||||||
m -= h * 60;
|
m -= h * 60;
|
||||||
return h + ":" + (m < 10 ? '0' : '') + m;
|
return h + ":" + (m < 10 ? "0" : "") + m;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findEngine(id) {
|
function findEngine(id) {
|
||||||
|
@ -212,14 +212,14 @@ OSM.Directions = function (map) {
|
||||||
|
|
||||||
OSM.router.replace("/directions?" + querystring.stringify({
|
OSM.router.replace("/directions?" + querystring.stringify({
|
||||||
engine: chosenEngine.id,
|
engine: chosenEngine.id,
|
||||||
route: o.lat.toFixed(precision) + ',' + o.lng.toFixed(precision) + ';' +
|
route: o.lat.toFixed(precision) + "," + o.lng.toFixed(precision) + ";" +
|
||||||
d.lat.toFixed(precision) + ',' + d.lng.toFixed(precision)
|
d.lat.toFixed(precision) + "," + d.lng.toFixed(precision)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// copy loading item to sidebar and display it. we copy it, rather than
|
// copy loading item to sidebar and display it. we copy it, rather than
|
||||||
// just using it in-place and replacing it in case it has to be used
|
// just using it in-place and replacing it in case it has to be used
|
||||||
// again.
|
// again.
|
||||||
$('#sidebar_content').html($('.directions_form .loader_copy').html());
|
$("#sidebar_content").html($(".directions_form .loader_copy").html());
|
||||||
map.setSidebarOverlaid(false);
|
map.setSidebarOverlaid(false);
|
||||||
|
|
||||||
awaitingRoute = chosenEngine.getRoute([o, d], function (err, route) {
|
awaitingRoute = chosenEngine.getRoute([o, d], function (err, route) {
|
||||||
|
@ -229,7 +229,7 @@ OSM.Directions = function (map) {
|
||||||
map.removeLayer(polyline);
|
map.removeLayer(polyline);
|
||||||
|
|
||||||
if (reportErrors) {
|
if (reportErrors) {
|
||||||
$('#sidebar_content').html('<p class="search_results_error">' + I18n.t('javascripts.directions.errors.no_route') + '</p>');
|
$("#sidebar_content").html("<p class=\"search_results_error\">" + I18n.t("javascripts.directions.errors.no_route") + "</p>");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -243,19 +243,19 @@ OSM.Directions = function (map) {
|
||||||
map.fitBounds(polyline.getBounds().pad(0.05));
|
map.fitBounds(polyline.getBounds().pad(0.05));
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = '<h2><a class="geolink" href="#">' +
|
var html = "<h2><a class=\"geolink\" href=\"#\">" +
|
||||||
'<span class="icon close"></span></a>' + I18n.t('javascripts.directions.directions') +
|
"<span class=\"icon close\"></span></a>" + I18n.t("javascripts.directions.directions") +
|
||||||
'</h2><p id="routing_summary">' +
|
"</h2><p id=\"routing_summary\">" +
|
||||||
I18n.t('javascripts.directions.distance') + ': ' + formatDistance(route.distance) + '. ' +
|
I18n.t("javascripts.directions.distance") + ": " + formatDistance(route.distance) + ". " +
|
||||||
I18n.t('javascripts.directions.time') + ': ' + formatTime(route.time) + '.';
|
I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".";
|
||||||
if (typeof route.ascend !== 'undefined' && typeof route.descend !== 'undefined') {
|
if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
|
||||||
html += '<br />' +
|
html += "<br />" +
|
||||||
I18n.t('javascripts.directions.ascend') + ': ' + Math.round(route.ascend) + 'm. ' +
|
I18n.t("javascripts.directions.ascend") + ": " + Math.round(route.ascend) + "m. " +
|
||||||
I18n.t('javascripts.directions.descend') + ': ' + Math.round(route.descend) +'m.';
|
I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) +"m.";
|
||||||
}
|
}
|
||||||
html += '</p><table id="turnbyturn" />';
|
html += "</p><table id=\"turnbyturn\" />";
|
||||||
|
|
||||||
$('#sidebar_content')
|
$("#sidebar_content")
|
||||||
.html(html);
|
.html(html);
|
||||||
|
|
||||||
// Add each row
|
// Add each row
|
||||||
|
@ -283,7 +283,7 @@ OSM.Directions = function (map) {
|
||||||
row.append("<td class='instruction'>" + instruction);
|
row.append("<td class='instruction'>" + instruction);
|
||||||
row.append("<td class='distance'>" + dist);
|
row.append("<td class='distance'>" + dist);
|
||||||
|
|
||||||
row.on('click', function () {
|
row.on("click", function () {
|
||||||
popup
|
popup
|
||||||
.setLatLng(ll)
|
.setLatLng(ll)
|
||||||
.setContent("<p>" + instruction + "</p>")
|
.setContent("<p>" + instruction + "</p>")
|
||||||
|
@ -298,32 +298,32 @@ OSM.Directions = function (map) {
|
||||||
map.removeLayer(highlight);
|
map.removeLayer(highlight);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#turnbyturn').append(row);
|
$("#turnbyturn").append(row);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#sidebar_content').append('<p id="routing_credit">' +
|
$("#sidebar_content").append("<p id=\"routing_credit\">" +
|
||||||
I18n.t('javascripts.directions.instructions.courtesy', {link: chosenEngine.creditline}) +
|
I18n.t("javascripts.directions.instructions.courtesy", {link: chosenEngine.creditline}) +
|
||||||
'</p>');
|
"</p>");
|
||||||
|
|
||||||
$('#sidebar_content a.geolink').on('click', function(e) {
|
$("#sidebar_content a.geolink").on("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
map.removeLayer(polyline);
|
map.removeLayer(polyline);
|
||||||
$('#sidebar_content').html('');
|
$("#sidebar_content").html("");
|
||||||
map.setSidebarOverlaid(true);
|
map.setSidebarOverlaid(true);
|
||||||
// TODO: collapse width of sidebar back to previous
|
// TODO: collapse width of sidebar back to previous
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var chosenEngineIndex = findEngine('fossgis_osrm_car');
|
var chosenEngineIndex = findEngine("fossgis_osrm_car");
|
||||||
if ($.cookie('_osm_directions_engine')) {
|
if ($.cookie("_osm_directions_engine")) {
|
||||||
chosenEngineIndex = findEngine($.cookie('_osm_directions_engine'));
|
chosenEngineIndex = findEngine($.cookie("_osm_directions_engine"));
|
||||||
}
|
}
|
||||||
setEngine(chosenEngineIndex);
|
setEngine(chosenEngineIndex);
|
||||||
|
|
||||||
select.on("change", function (e) {
|
select.on("change", function (e) {
|
||||||
chosenEngine = engines[e.target.selectedIndex];
|
chosenEngine = engines[e.target.selectedIndex];
|
||||||
$.cookie('_osm_directions_engine', chosenEngine.id, { expires: expiry, path: '/' });
|
$.cookie("_osm_directions_engine", chosenEngine.id, { expires: expiry, path: "/" });
|
||||||
if (map.hasLayer(polyline)) {
|
if (map.hasLayer(polyline)) {
|
||||||
getRoute(true, true);
|
getRoute(true, true);
|
||||||
}
|
}
|
||||||
|
@ -334,11 +334,11 @@ OSM.Directions = function (map) {
|
||||||
getRoute(true, true);
|
getRoute(true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".routing_marker").on('dragstart', function (e) {
|
$(".routing_marker").on("dragstart", function (e) {
|
||||||
var dt = e.originalEvent.dataTransfer;
|
var dt = e.originalEvent.dataTransfer;
|
||||||
dt.effectAllowed = 'move';
|
dt.effectAllowed = "move";
|
||||||
var dragData = { type: $(this).data('type') };
|
var dragData = { type: $(this).data("type") };
|
||||||
dt.setData('text', JSON.stringify(dragData));
|
dt.setData("text", JSON.stringify(dragData));
|
||||||
if (dt.setDragImage) {
|
if (dt.setDragImage) {
|
||||||
var img = $("<img>").attr("src", $(e.originalEvent.target).attr("src"));
|
var img = $("<img>").attr("src", $(e.originalEvent.target).attr("src"));
|
||||||
dt.setDragImage(img.get(0), 12, 21);
|
dt.setDragImage(img.get(0), 12, 21);
|
||||||
|
@ -351,26 +351,26 @@ OSM.Directions = function (map) {
|
||||||
$(".search_form").hide();
|
$(".search_form").hide();
|
||||||
$(".directions_form").show();
|
$(".directions_form").show();
|
||||||
|
|
||||||
$("#map").on('dragend dragover', function (e) {
|
$("#map").on("dragend dragover", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#map").on('drop', function (e) {
|
$("#map").on("drop", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var oe = e.originalEvent;
|
var oe = e.originalEvent;
|
||||||
var dragData = JSON.parse(oe.dataTransfer.getData('text'));
|
var dragData = JSON.parse(oe.dataTransfer.getData("text"));
|
||||||
var type = dragData.type;
|
var type = dragData.type;
|
||||||
var pt = L.DomEvent.getMousePosition(oe, map.getContainer()); // co-ordinates of the mouse pointer at present
|
var pt = L.DomEvent.getMousePosition(oe, map.getContainer()); // co-ordinates of the mouse pointer at present
|
||||||
pt.y += 20;
|
pt.y += 20;
|
||||||
var ll = map.containerPointToLatLng(pt);
|
var ll = map.containerPointToLatLng(pt);
|
||||||
endpoints[type === 'from' ? 0 : 1].setLatLng(ll);
|
endpoints[type === "from" ? 0 : 1].setLatLng(ll);
|
||||||
getRoute(true, true);
|
getRoute(true, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
var params = querystring.parse(location.search.substring(1)),
|
var params = querystring.parse(location.search.substring(1)),
|
||||||
route = (params.route || '').split(';'),
|
route = (params.route || "").split(";"),
|
||||||
from = route[0] && L.latLng(route[0].split(',')),
|
from = route[0] && L.latLng(route[0].split(",")),
|
||||||
to = route[1] && L.latLng(route[1].split(','));
|
to = route[1] && L.latLng(route[1].split(","));
|
||||||
|
|
||||||
if (params.engine) {
|
if (params.engine) {
|
||||||
var engineIndex = findEngine(params.engine);
|
var engineIndex = findEngine(params.engine);
|
||||||
|
@ -395,7 +395,7 @@ OSM.Directions = function (map) {
|
||||||
page.unload = function() {
|
page.unload = function() {
|
||||||
$(".search_form").show();
|
$(".search_form").show();
|
||||||
$(".directions_form").hide();
|
$(".directions_form").hide();
|
||||||
$("#map").off('dragend dragover drop');
|
$("#map").off("dragend dragover drop");
|
||||||
|
|
||||||
map
|
map
|
||||||
.removeLayer(popup)
|
.removeLayer(popup)
|
||||||
|
|
|
@ -6,63 +6,63 @@ function FOSSGISEngine(id, vehicleType) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
creditline: '<a href="https://routing.openstreetmap.de/about.html" target="_blank">FOSSGIS Routing Service</a>',
|
creditline: "<a href=\"https://routing.openstreetmap.de/about.html\" target=\"_blank\">FOSSGIS Routing Service</a>",
|
||||||
draggable: true,
|
draggable: true,
|
||||||
|
|
||||||
_transformSteps: function(input_steps, line) {
|
_transformSteps: function(input_steps, line) {
|
||||||
var INSTRUCTION_TEMPLATE = {
|
var INSTRUCTION_TEMPLATE = {
|
||||||
'continue': 'javascripts.directions.instructions.continue',
|
"continue": "javascripts.directions.instructions.continue",
|
||||||
'merge right': 'javascripts.directions.instructions.merge_right',
|
"merge right": "javascripts.directions.instructions.merge_right",
|
||||||
'merge left': 'javascripts.directions.instructions.merge_left',
|
"merge left": "javascripts.directions.instructions.merge_left",
|
||||||
'off ramp right': 'javascripts.directions.instructions.offramp_right',
|
"off ramp right": "javascripts.directions.instructions.offramp_right",
|
||||||
'off ramp left': 'javascripts.directions.instructions.offramp_left',
|
"off ramp left": "javascripts.directions.instructions.offramp_left",
|
||||||
'on ramp right': 'javascripts.directions.instructions.onramp_right',
|
"on ramp right": "javascripts.directions.instructions.onramp_right",
|
||||||
'on ramp left': 'javascripts.directions.instructions.onramp_left',
|
"on ramp left": "javascripts.directions.instructions.onramp_left",
|
||||||
'fork right': 'javascripts.directions.instructions.fork_right',
|
"fork right": "javascripts.directions.instructions.fork_right",
|
||||||
'fork left': 'javascripts.directions.instructions.fork_left',
|
"fork left": "javascripts.directions.instructions.fork_left",
|
||||||
'end of road right': 'javascripts.directions.instructions.endofroad_right',
|
"end of road right": "javascripts.directions.instructions.endofroad_right",
|
||||||
'end of road left': 'javascripts.directions.instructions.endofroad_left',
|
"end of road left": "javascripts.directions.instructions.endofroad_left",
|
||||||
'turn straight': 'javascripts.directions.instructions.continue',
|
"turn straight": "javascripts.directions.instructions.continue",
|
||||||
'turn slight right': 'javascripts.directions.instructions.slight_right',
|
"turn slight right": "javascripts.directions.instructions.slight_right",
|
||||||
'turn right': 'javascripts.directions.instructions.turn_right',
|
"turn right": "javascripts.directions.instructions.turn_right",
|
||||||
'turn sharp right': 'javascripts.directions.instructions.sharp_right',
|
"turn sharp right": "javascripts.directions.instructions.sharp_right",
|
||||||
'turn uturn': 'javascripts.directions.instructions.uturn',
|
"turn uturn": "javascripts.directions.instructions.uturn",
|
||||||
'turn sharp left': 'javascripts.directions.instructions.sharp_left',
|
"turn sharp left": "javascripts.directions.instructions.sharp_left",
|
||||||
'turn left': 'javascripts.directions.instructions.turn_left',
|
"turn left": "javascripts.directions.instructions.turn_left",
|
||||||
'turn slight left': 'javascripts.directions.instructions.slight_left',
|
"turn slight left": "javascripts.directions.instructions.slight_left",
|
||||||
'roundabout': 'javascripts.directions.instructions.roundabout',
|
"roundabout": "javascripts.directions.instructions.roundabout",
|
||||||
'rotary': 'javascripts.directions.instructions.roundabout',
|
"rotary": "javascripts.directions.instructions.roundabout",
|
||||||
'exit roundabout': 'javascripts.directions.instructions.exit_roundabout',
|
"exit roundabout": "javascripts.directions.instructions.exit_roundabout",
|
||||||
'exit rotary': 'javascripts.directions.instructions.exit_roundabout',
|
"exit rotary": "javascripts.directions.instructions.exit_roundabout",
|
||||||
'depart': 'javascripts.directions.instructions.start',
|
"depart": "javascripts.directions.instructions.start",
|
||||||
'arrive': 'javascripts.directions.instructions.destination',
|
"arrive": "javascripts.directions.instructions.destination",
|
||||||
};
|
};
|
||||||
var ICON_MAP = {
|
var ICON_MAP = {
|
||||||
'continue': 0,
|
"continue": 0,
|
||||||
'merge right': 21,
|
"merge right": 21,
|
||||||
'merge left': 20,
|
"merge left": 20,
|
||||||
'off ramp right': 24,
|
"off ramp right": 24,
|
||||||
'off ramp left': 25,
|
"off ramp left": 25,
|
||||||
'on ramp right': 2,
|
"on ramp right": 2,
|
||||||
'on ramp left': 6,
|
"on ramp left": 6,
|
||||||
'fork right': 18,
|
"fork right": 18,
|
||||||
'fork left': 19,
|
"fork left": 19,
|
||||||
'end of road right': 22,
|
"end of road right": 22,
|
||||||
'end of road left': 23,
|
"end of road left": 23,
|
||||||
'turn straight': 0,
|
"turn straight": 0,
|
||||||
'turn slight right': 1,
|
"turn slight right": 1,
|
||||||
'turn right': 2,
|
"turn right": 2,
|
||||||
'turn sharp right': 3,
|
"turn sharp right": 3,
|
||||||
'turn uturn': 4,
|
"turn uturn": 4,
|
||||||
'turn slight left': 5,
|
"turn slight left": 5,
|
||||||
'turn left': 6,
|
"turn left": 6,
|
||||||
'turn sharp left': 7,
|
"turn sharp left": 7,
|
||||||
'roundabout': 10,
|
"roundabout": 10,
|
||||||
'rotary': 10,
|
"rotary": 10,
|
||||||
'exit roundabout': 10,
|
"exit roundabout": 10,
|
||||||
'exit rotary': 10,
|
"exit rotary": 10,
|
||||||
'depart': 8,
|
"depart": 8,
|
||||||
'arrive': 14
|
"arrive": 14
|
||||||
};
|
};
|
||||||
var numToWord = function(num) {
|
var numToWord = function(num) {
|
||||||
return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num-1];
|
return ["first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"][num-1];
|
||||||
|
@ -72,23 +72,23 @@ function FOSSGISEngine(id, vehicleType) {
|
||||||
|
|
||||||
// special case handling
|
// special case handling
|
||||||
switch (step.maneuver.type) {
|
switch (step.maneuver.type) {
|
||||||
case 'on ramp':
|
case "on ramp":
|
||||||
case 'off ramp':
|
case "off ramp":
|
||||||
case 'merge':
|
case "merge":
|
||||||
case 'end of road':
|
case "end of road":
|
||||||
case 'fork':
|
case "fork":
|
||||||
maneuver_id = step.maneuver.type + ' ' + (step.maneuver.modifier.indexOf('left') >= 0 ? 'left' : 'right');
|
maneuver_id = step.maneuver.type + " " + (step.maneuver.modifier.indexOf("left") >= 0 ? "left" : "right");
|
||||||
break;
|
break;
|
||||||
case 'depart':
|
case "depart":
|
||||||
case 'arrive':
|
case "arrive":
|
||||||
case 'roundabout':
|
case "roundabout":
|
||||||
case 'rotary':
|
case "rotary":
|
||||||
case 'exit roundabout':
|
case "exit roundabout":
|
||||||
case 'exit rotary':
|
case "exit rotary":
|
||||||
maneuver_id = step.maneuver.type;
|
maneuver_id = step.maneuver.type;
|
||||||
break;
|
break;
|
||||||
case 'roundabout turn':
|
case "roundabout turn":
|
||||||
case 'turn':
|
case "turn":
|
||||||
maneuver_id = "turn " + step.maneuver.modifier;
|
maneuver_id = "turn " + step.maneuver.modifier;
|
||||||
break;
|
break;
|
||||||
// for unknown types the fallback is turn
|
// for unknown types the fallback is turn
|
||||||
|
@ -115,7 +115,7 @@ function FOSSGISEngine(id, vehicleType) {
|
||||||
} else if (step.ref) {
|
} else if (step.ref) {
|
||||||
name = "<b>" + step.ref + "</b>";
|
name = "<b>" + step.ref + "</b>";
|
||||||
} else {
|
} else {
|
||||||
name = I18n.t('javascripts.directions.instructions.unnamed');
|
name = I18n.t("javascripts.directions.instructions.unnamed");
|
||||||
namedRoad = false;
|
namedRoad = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,12 +124,12 @@ function FOSSGISEngine(id, vehicleType) {
|
||||||
} else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) {
|
} else if (step.maneuver.type.match(/^(rotary|roundabout)$/)) {
|
||||||
if (step.maneuver.exit) {
|
if (step.maneuver.exit) {
|
||||||
if (step.maneuver.exit <= 10) {
|
if (step.maneuver.exit <= 10) {
|
||||||
instText += I18n.t(template + '_with_exit_ordinal', { exit: I18n.t('javascripts.directions.instructions.exit_counts.' + numToWord(step.maneuver.exit)), name: name });
|
instText += I18n.t(template + "_with_exit_ordinal", { exit: I18n.t("javascripts.directions.instructions.exit_counts." + numToWord(step.maneuver.exit)), name: name });
|
||||||
} else {
|
} else {
|
||||||
instText += I18n.t(template + '_with_exit', { exit: step.maneuver.exit, name: name });
|
instText += I18n.t(template + "_with_exit", { exit: step.maneuver.exit, name: name });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
instText += I18n.t(template + '_without_exit', { name: name });
|
instText += I18n.t(template + "_without_exit", { name: name });
|
||||||
}
|
}
|
||||||
} else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) {
|
} else if (step.maneuver.type.match(/^(on ramp|off ramp)$/)) {
|
||||||
var params = {};
|
var params = {};
|
||||||
|
@ -141,7 +141,7 @@ function FOSSGISEngine(id, vehicleType) {
|
||||||
}
|
}
|
||||||
instText += I18n.t(template, params);
|
instText += I18n.t(template, params);
|
||||||
} else {
|
} else {
|
||||||
instText += I18n.t(template + '_without_exit', { name: name });
|
instText += I18n.t(template + "_without_exit", { name: name });
|
||||||
}
|
}
|
||||||
return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry];
|
return [[step.maneuver.location[1], step.maneuver.location[0]], ICON_MAP[maneuver_id], instText, step.distance, step_geometry];
|
||||||
});
|
});
|
||||||
|
@ -166,13 +166,13 @@ function FOSSGISEngine(id, vehicleType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var encoded_coords = points.map(function(p) {
|
var encoded_coords = points.map(function(p) {
|
||||||
return p.lng + ',' + p.lat;
|
return p.lng + "," + p.lat;
|
||||||
}).join(';');
|
}).join(";");
|
||||||
|
|
||||||
var req_url = OSM.FOSSGIS_OSRM_URL + "routed-" + vehicleType + "/route/v1/driving/" + encoded_coords;
|
var req_url = OSM.FOSSGIS_OSRM_URL + "routed-" + vehicleType + "/route/v1/driving/" + encoded_coords;
|
||||||
|
|
||||||
var onResponse = function (data) {
|
var onResponse = function (data) {
|
||||||
if (data.code !== 'Ok')
|
if (data.code !== "Ok")
|
||||||
return callback(true);
|
return callback(true);
|
||||||
|
|
||||||
cachedHints = data.waypoints.map(function(wp) {
|
cachedHints = data.waypoints.map(function(wp) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ function GraphHopperEngine(id, vehicleType) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
creditline: '<a href="https://www.graphhopper.com/" target="_blank">Graphhopper</a>',
|
creditline: "<a href=\"https://www.graphhopper.com/\" target=\"_blank\">Graphhopper</a>",
|
||||||
draggable: false,
|
draggable: false,
|
||||||
|
|
||||||
getRoute: function (points, callback) {
|
getRoute: function (points, callback) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ OSM.History = function(map) {
|
||||||
.on("mousedown", "[data-changeset]", function () {
|
.on("mousedown", "[data-changeset]", function () {
|
||||||
var moved = false;
|
var moved = false;
|
||||||
$(this).one("click", function (e) {
|
$(this).one("click", function (e) {
|
||||||
if (!moved && !$(e.target).is('a')) {
|
if (!moved && !$(e.target).is("a")) {
|
||||||
clickChangeset($(this).data("changeset").id, e);
|
clickChangeset($(this).data("changeset").id, e);
|
||||||
}
|
}
|
||||||
}).one("mousemove", function () {
|
}).one("mousemove", function () {
|
||||||
|
@ -52,9 +52,9 @@ OSM.History = function(map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var data = {list: '1'};
|
var data = {list: "1"};
|
||||||
|
|
||||||
if (window.location.pathname === '/history') {
|
if (window.location.pathname === "/history") {
|
||||||
data.bbox = map.getBounds().wrap().toBBoxString();
|
data.bbox = map.getBounds().wrap().toBBoxString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,15 +63,15 @@ OSM.History = function(map) {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
data: data,
|
data: data,
|
||||||
success: function(html) {
|
success: function(html) {
|
||||||
$('#sidebar_content .changesets').html(html);
|
$("#sidebar_content .changesets").html(html);
|
||||||
updateMap();
|
updateMap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var feedLink = $('link[type="application/atom+xml"]'),
|
var feedLink = $("link[type=\"application/atom+xml\"]"),
|
||||||
feedHref = feedLink.attr('href').split('?')[0];
|
feedHref = feedLink.attr("href").split("?")[0];
|
||||||
|
|
||||||
feedLink.attr('href', feedHref + '?bbox=' + data.bbox);
|
feedLink.attr("href", feedHref + "?bbox=" + data.bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadMore(e) {
|
function loadMore(e) {
|
||||||
|
@ -130,14 +130,14 @@ OSM.History = function(map) {
|
||||||
|
|
||||||
function updateMap() {
|
function updateMap() {
|
||||||
changesets = $("[data-changeset]").map(function (index,element) {
|
changesets = $("[data-changeset]").map(function (index,element) {
|
||||||
return $(element).data('changeset');
|
return $(element).data("changeset");
|
||||||
}).get().filter(function (changeset) {
|
}).get().filter(function (changeset) {
|
||||||
return changeset.bbox;
|
return changeset.bbox;
|
||||||
});
|
});
|
||||||
|
|
||||||
updateBounds();
|
updateBounds();
|
||||||
|
|
||||||
if (window.location.pathname !== '/history') {
|
if (window.location.pathname !== "/history") {
|
||||||
var bounds = group.getBounds();
|
var bounds = group.getBounds();
|
||||||
if (bounds.isValid()) map.fitBounds(bounds);
|
if (bounds.isValid()) map.fitBounds(bounds);
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ OSM.History = function(map) {
|
||||||
page.load = function() {
|
page.load = function() {
|
||||||
map.addLayer(group);
|
map.addLayer(group);
|
||||||
|
|
||||||
if (window.location.pathname === '/history') {
|
if (window.location.pathname === "/history") {
|
||||||
map.on("moveend", update);
|
map.on("moveend", update);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
OSM.NewNote = function(map) {
|
OSM.NewNote = function(map) {
|
||||||
var noteLayer = map.noteLayer,
|
var noteLayer = map.noteLayer,
|
||||||
content = $('#sidebar_content'),
|
content = $("#sidebar_content"),
|
||||||
page = {},
|
page = {},
|
||||||
addNoteButton = $(".control-note .control-button"),
|
addNoteButton = $(".control-note .control-button"),
|
||||||
newNote,
|
newNote,
|
||||||
|
@ -28,9 +28,9 @@ OSM.NewNote = function(map) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
if ($(this).hasClass('disabled')) return;
|
if ($(this).hasClass("disabled")) return;
|
||||||
|
|
||||||
OSM.router.route('/note/new');
|
OSM.router.route("/note/new");
|
||||||
});
|
});
|
||||||
|
|
||||||
function createNote(marker, form, url) {
|
function createNote(marker, form, url) {
|
||||||
|
@ -61,7 +61,7 @@ OSM.NewNote = function(map) {
|
||||||
newNote = null;
|
newNote = null;
|
||||||
noteLayer.removeLayer(marker);
|
noteLayer.removeLayer(marker);
|
||||||
addNoteButton.removeClass("active");
|
addNoteButton.removeClass("active");
|
||||||
OSM.router.route('/note/' + feature.properties.id);
|
OSM.router.route("/note/" + feature.properties.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ OSM.NewNote = function(map) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function newHalo(loc, a) {
|
function newHalo(loc, a) {
|
||||||
if (a === 'dragstart' && map.hasLayer(halo)) {
|
if (a === "dragstart" && map.hasLayer(halo)) {
|
||||||
map.removeLayer(halo);
|
map.removeLayer(halo);
|
||||||
} else {
|
} else {
|
||||||
if (map.hasLayer(halo)) map.removeLayer(halo);
|
if (map.hasLayer(halo)) map.removeLayer(halo);
|
||||||
|
@ -107,7 +107,7 @@ OSM.NewNote = function(map) {
|
||||||
|
|
||||||
map.addLayer(noteLayer);
|
map.addLayer(noteLayer);
|
||||||
|
|
||||||
var params = querystring.parse(path.substring(path.indexOf('?') + 1));
|
var params = querystring.parse(path.substring(path.indexOf("?") + 1));
|
||||||
var markerLatlng;
|
var markerLatlng;
|
||||||
|
|
||||||
if (params.lat && params.lon) {
|
if (params.lat && params.lon) {
|
||||||
|
@ -149,9 +149,9 @@ OSM.NewNote = function(map) {
|
||||||
$(e.target.form.add).prop("disabled", $(e.target).val() === "");
|
$(e.target.form.add).prop("disabled", $(e.target).val() === "");
|
||||||
}
|
}
|
||||||
|
|
||||||
content.find('input[type=submit]').on('click', function (e) {
|
content.find("input[type=submit]").on("click", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
createNote(newNote, e.target.form, '/api/0.6/notes.json');
|
createNote(newNote, e.target.form, "/api/0.6/notes.json");
|
||||||
});
|
});
|
||||||
|
|
||||||
return map.getState();
|
return map.getState();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
OSM.Note = function (map) {
|
OSM.Note = function (map) {
|
||||||
var content = $('#sidebar_content'),
|
var content = $("#sidebar_content"),
|
||||||
page = {},
|
page = {},
|
||||||
halo, currentNote;
|
halo, currentNote;
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ OSM.Note = function (map) {
|
||||||
page.pushstate = page.popstate = function (path) {
|
page.pushstate = page.popstate = function (path) {
|
||||||
OSM.loadSidebarContent(path, function() {
|
OSM.loadSidebarContent(path, function() {
|
||||||
initialize(function() {
|
initialize(function() {
|
||||||
var data = $('.details').data(),
|
var data = $(".details").data(),
|
||||||
latLng = L.latLng(data.coordinates.split(','));
|
latLng = L.latLng(data.coordinates.split(","));
|
||||||
if (!map.getBounds().contains(latLng)) moveToNote();
|
if (!map.getBounds().contains(latLng)) moveToNote();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -68,10 +68,10 @@ OSM.Note = function (map) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
content.find("textarea").val('').trigger("input");
|
content.find("textarea").val("").trigger("input");
|
||||||
|
|
||||||
var data = $('.details').data(),
|
var data = $(".details").data(),
|
||||||
latLng = L.latLng(data.coordinates.split(','));
|
latLng = L.latLng(data.coordinates.split(","));
|
||||||
|
|
||||||
if (!map.hasLayer(halo)) {
|
if (!map.hasLayer(halo)) {
|
||||||
halo = L.circleMarker(latLng, {
|
halo = L.circleMarker(latLng, {
|
||||||
|
@ -96,8 +96,8 @@ OSM.Note = function (map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveToNote() {
|
function moveToNote() {
|
||||||
var data = $('.details').data(),
|
var data = $(".details").data(),
|
||||||
latLng = L.latLng(data.coordinates.split(','));
|
latLng = L.latLng(data.coordinates.split(","));
|
||||||
|
|
||||||
if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
|
if (!window.location.hash || window.location.hash.match(/^#?c[0-9]+$/)) {
|
||||||
OSM.router.withoutMoveListener(function () {
|
OSM.router.withoutMoveListener(function () {
|
||||||
|
|
|
@ -33,9 +33,9 @@ OSM.initializeNotes = function (map) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
noteLayer.on('click', function(e) {
|
noteLayer.on("click", function(e) {
|
||||||
if (e.layer.id) {
|
if (e.layer.id) {
|
||||||
OSM.router.route('/note/' + e.layer.id);
|
OSM.router.route("/note/" + e.layer.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
OSM.Query = function(map) {
|
OSM.Query = function(map) {
|
||||||
var url = OSM.OVERPASS_URL,
|
var url = OSM.OVERPASS_URL,
|
||||||
queryButton = $(".control-query .control-button"),
|
queryButton = $(".control-query .control-button"),
|
||||||
uninterestingTags = ['source', 'source_ref', 'source:ref', 'history', 'attribution', 'created_by', 'tiger:county', 'tiger:tlid', 'tiger:upload_uuid', 'KSJ2:curve_id', 'KSJ2:lat', 'KSJ2:lon', 'KSJ2:coordinate', 'KSJ2:filename', 'note:ja'],
|
uninterestingTags = ["source", "source_ref", "source:ref", "history", "attribution", "created_by", "tiger:county", "tiger:tlid", "tiger:upload_uuid", "KSJ2:curve_id", "KSJ2:lat", "KSJ2:lon", "KSJ2:coordinate", "KSJ2:filename", "note:ja"],
|
||||||
marker;
|
marker;
|
||||||
|
|
||||||
var featureStyle = {
|
var featureStyle = {
|
||||||
|
@ -55,7 +55,7 @@ OSM.Query = function(map) {
|
||||||
var geometry = $(this).data("geometry");
|
var geometry = $(this).data("geometry");
|
||||||
if (geometry) map.removeLayer(geometry);
|
if (geometry) map.removeLayer(geometry);
|
||||||
|
|
||||||
if (!$(e.target).is('a')) {
|
if (!$(e.target).is("a")) {
|
||||||
$(this).find("a").simulate("click", e);
|
$(this).find("a").simulate("click", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ OSM.Query = function(map) {
|
||||||
};
|
};
|
||||||
|
|
||||||
page.load = function(path, noCentre) {
|
page.load = function(path, noCentre) {
|
||||||
var params = querystring.parse(path.substring(path.indexOf('?') + 1)),
|
var params = querystring.parse(path.substring(path.indexOf("?") + 1)),
|
||||||
latlng = L.latLng(params.lat, params.lon);
|
latlng = L.latLng(params.lat, params.lon);
|
||||||
|
|
||||||
if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) {
|
if (!window.location.hash && !noCentre && !map.getBounds().contains(latlng)) {
|
||||||
|
|
|
@ -47,7 +47,7 @@ OSM.Search = function(map) {
|
||||||
.on("mousedown", "p.search_results_entry:has(a.set_position)", function () {
|
.on("mousedown", "p.search_results_entry:has(a.set_position)", function () {
|
||||||
var moved = false;
|
var moved = false;
|
||||||
$(this).one("click", function (e) {
|
$(this).one("click", function (e) {
|
||||||
if (!moved && !$(e.target).is('a')) {
|
if (!moved && !$(e.target).is("a")) {
|
||||||
$(this).find("a.set_position").simulate("click", e);
|
$(this).find("a.set_position").simulate("click", e);
|
||||||
}
|
}
|
||||||
}).one("mousemove", function () {
|
}).one("mousemove", function () {
|
||||||
|
@ -120,7 +120,7 @@ OSM.Search = function(map) {
|
||||||
var page = {};
|
var page = {};
|
||||||
|
|
||||||
page.pushstate = page.popstate = function(path) {
|
page.pushstate = page.popstate = function(path) {
|
||||||
var params = querystring.parse(path.substring(path.indexOf('?') + 1));
|
var params = querystring.parse(path.substring(path.indexOf("?") + 1));
|
||||||
$(".search_form input[name=query]").val(params.query);
|
$(".search_form input[name=query]").val(params.query);
|
||||||
$(".describe_location").hide();
|
$(".describe_location").hide();
|
||||||
OSM.loadSidebarContent(path, page.load);
|
OSM.loadSidebarContent(path, page.load);
|
||||||
|
@ -131,7 +131,7 @@ OSM.Search = function(map) {
|
||||||
var entry = $(this);
|
var entry = $(this);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: entry.data("href"),
|
url: entry.data("href"),
|
||||||
method: 'GET',
|
method: "GET",
|
||||||
data: {
|
data: {
|
||||||
zoom: map.getZoom(),
|
zoom: map.getZoom(),
|
||||||
minlon: map.getBounds().getWest(),
|
minlon: map.getBounds().getWest(),
|
||||||
|
@ -143,7 +143,7 @@ OSM.Search = function(map) {
|
||||||
entry.html(html);
|
entry.html(html);
|
||||||
// go to first result of first geocoder
|
// go to first result of first geocoder
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
var firstResult = entry.find('*[data-lat][data-lon]:first').first();
|
var firstResult = entry.find("*[data-lat][data-lon]:first").first();
|
||||||
if (firstResult.length) {
|
if (firstResult.length) {
|
||||||
panToSearchResult(firstResult.data());
|
panToSearchResult(firstResult.data());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,78 +2,78 @@ L.OSM.key = function (options) {
|
||||||
var control = L.control(options);
|
var control = L.control(options);
|
||||||
|
|
||||||
control.onAdd = function (map) {
|
control.onAdd = function (map) {
|
||||||
var $container = $('<div>')
|
var $container = $("<div>")
|
||||||
.attr('class', 'control-key');
|
.attr("class", "control-key");
|
||||||
|
|
||||||
var button = $('<a>')
|
var button = $("<a>")
|
||||||
.attr('class', 'control-button')
|
.attr("class", "control-button")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.html('<span class="icon key"></span>')
|
.html("<span class=\"icon key\"></span>")
|
||||||
.on('click', toggle)
|
.on("click", toggle)
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
|
|
||||||
var $ui = $('<div>')
|
var $ui = $("<div>")
|
||||||
.attr('class', 'key-ui');
|
.attr("class", "key-ui");
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'sidebar_heading')
|
.attr("class", "sidebar_heading")
|
||||||
.appendTo($ui)
|
.appendTo($ui)
|
||||||
.append(
|
.append(
|
||||||
$('<span>')
|
$("<span>")
|
||||||
.text(I18n.t('javascripts.close'))
|
.text(I18n.t("javascripts.close"))
|
||||||
.attr('class', 'icon close')
|
.attr("class", "icon close")
|
||||||
.bind('click', toggle))
|
.bind("click", toggle))
|
||||||
.append(
|
.append(
|
||||||
$('<h4>')
|
$("<h4>")
|
||||||
.text(I18n.t('javascripts.key.title')));
|
.text(I18n.t("javascripts.key.title")));
|
||||||
|
|
||||||
var $section = $('<div>')
|
var $section = $("<div>")
|
||||||
.attr('class', 'section')
|
.attr("class", "section")
|
||||||
.appendTo($ui);
|
.appendTo($ui);
|
||||||
|
|
||||||
options.sidebar.addPane($ui);
|
options.sidebar.addPane($ui);
|
||||||
|
|
||||||
$ui
|
$ui
|
||||||
.on('show', shown)
|
.on("show", shown)
|
||||||
.on('hide', hidden);
|
.on("hide", hidden);
|
||||||
|
|
||||||
map.on('baselayerchange', updateButton);
|
map.on("baselayerchange", updateButton);
|
||||||
|
|
||||||
updateButton();
|
updateButton();
|
||||||
|
|
||||||
function shown() {
|
function shown() {
|
||||||
map.on('zoomend baselayerchange', update);
|
map.on("zoomend baselayerchange", update);
|
||||||
$section.load('/key', update);
|
$section.load("/key", update);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hidden() {
|
function hidden() {
|
||||||
map.off('zoomend baselayerchange', update);
|
map.off("zoomend baselayerchange", update);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle(e) {
|
function toggle(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!button.hasClass('disabled')) {
|
if (!button.hasClass("disabled")) {
|
||||||
options.sidebar.togglePane($ui, button);
|
options.sidebar.togglePane($ui, button);
|
||||||
}
|
}
|
||||||
$('.leaflet-control .control-button').tooltip('hide');
|
$(".leaflet-control .control-button").tooltip("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateButton() {
|
function updateButton() {
|
||||||
var disabled = ['mapnik', 'cyclemap'].indexOf(map.getMapBaseLayerId()) === -1;
|
var disabled = ["mapnik", "cyclemap"].indexOf(map.getMapBaseLayerId()) === -1;
|
||||||
button
|
button
|
||||||
.toggleClass('disabled', disabled)
|
.toggleClass("disabled", disabled)
|
||||||
.attr('data-original-title',
|
.attr("data-original-title",
|
||||||
I18n.t(disabled ?
|
I18n.t(disabled ?
|
||||||
'javascripts.key.tooltip_disabled' :
|
"javascripts.key.tooltip_disabled" :
|
||||||
'javascripts.key.tooltip'));
|
"javascripts.key.tooltip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var layer = map.getMapBaseLayerId(),
|
var layer = map.getMapBaseLayerId(),
|
||||||
zoom = map.getZoom();
|
zoom = map.getZoom();
|
||||||
|
|
||||||
$('.mapkey-table-entry').each(function () {
|
$(".mapkey-table-entry").each(function () {
|
||||||
var data = $(this).data();
|
var data = $(this).data();
|
||||||
if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
|
if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
|
||||||
$(this).show();
|
$(this).show();
|
||||||
|
|
|
@ -4,48 +4,48 @@ L.OSM.layers = function(options) {
|
||||||
control.onAdd = function (map) {
|
control.onAdd = function (map) {
|
||||||
var layers = options.layers;
|
var layers = options.layers;
|
||||||
|
|
||||||
var $container = $('<div>')
|
var $container = $("<div>")
|
||||||
.attr('class', 'control-layers');
|
.attr("class", "control-layers");
|
||||||
|
|
||||||
var button = $('<a>')
|
var button = $("<a>")
|
||||||
.attr('class', 'control-button')
|
.attr("class", "control-button")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.attr('title', I18n.t('javascripts.map.layers.title'))
|
.attr("title", I18n.t("javascripts.map.layers.title"))
|
||||||
.html('<span class="icon layers"></span>')
|
.html("<span class=\"icon layers\"></span>")
|
||||||
.on('click', toggle)
|
.on("click", toggle)
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
|
|
||||||
var $ui = $('<div>')
|
var $ui = $("<div>")
|
||||||
.attr('class', 'layers-ui');
|
.attr("class", "layers-ui");
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'sidebar_heading')
|
.attr("class", "sidebar_heading")
|
||||||
.appendTo($ui)
|
.appendTo($ui)
|
||||||
.append(
|
.append(
|
||||||
$('<span>')
|
$("<span>")
|
||||||
.text(I18n.t('javascripts.close'))
|
.text(I18n.t("javascripts.close"))
|
||||||
.attr('class', 'icon close')
|
.attr("class", "icon close")
|
||||||
.bind('click', toggle))
|
.bind("click", toggle))
|
||||||
.append(
|
.append(
|
||||||
$('<h4>')
|
$("<h4>")
|
||||||
.text(I18n.t('javascripts.map.layers.header')));
|
.text(I18n.t("javascripts.map.layers.header")));
|
||||||
|
|
||||||
var baseSection = $('<div>')
|
var baseSection = $("<div>")
|
||||||
.attr('class', 'section base-layers')
|
.attr("class", "section base-layers")
|
||||||
.appendTo($ui);
|
.appendTo($ui);
|
||||||
|
|
||||||
var baseLayers = $('<ul>')
|
var baseLayers = $("<ul>")
|
||||||
.appendTo(baseSection);
|
.appendTo(baseSection);
|
||||||
|
|
||||||
layers.forEach(function(layer) {
|
layers.forEach(function(layer) {
|
||||||
var item = $('<li>')
|
var item = $("<li>")
|
||||||
.appendTo(baseLayers);
|
.appendTo(baseLayers);
|
||||||
|
|
||||||
if (map.hasLayer(layer)) {
|
if (map.hasLayer(layer)) {
|
||||||
item.addClass('active');
|
item.addClass("active");
|
||||||
}
|
}
|
||||||
|
|
||||||
var div = $('<div>')
|
var div = $("<div>")
|
||||||
.appendTo(item);
|
.appendTo(item);
|
||||||
|
|
||||||
map.whenReady(function() {
|
map.whenReady(function() {
|
||||||
|
@ -58,17 +58,17 @@ L.OSM.layers = function(options) {
|
||||||
miniMap.scrollWheelZoom.disable();
|
miniMap.scrollWheelZoom.disable();
|
||||||
|
|
||||||
$ui
|
$ui
|
||||||
.on('show', shown)
|
.on("show", shown)
|
||||||
.on('hide', hide);
|
.on("hide", hide);
|
||||||
|
|
||||||
function shown() {
|
function shown() {
|
||||||
miniMap.invalidateSize();
|
miniMap.invalidateSize();
|
||||||
setView({animate: false});
|
setView({animate: false});
|
||||||
map.on('moveend', moved);
|
map.on("moveend", moved);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
map.off('moveend', moved);
|
map.off("moveend", moved);
|
||||||
}
|
}
|
||||||
|
|
||||||
function moved() {
|
function moved() {
|
||||||
|
@ -80,17 +80,17 @@ L.OSM.layers = function(options) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var label = $('<label>')
|
var label = $("<label>")
|
||||||
.appendTo(item);
|
.appendTo(item);
|
||||||
|
|
||||||
var input = $('<input>')
|
var input = $("<input>")
|
||||||
.attr('type', 'radio')
|
.attr("type", "radio")
|
||||||
.prop('checked', map.hasLayer(layer))
|
.prop("checked", map.hasLayer(layer))
|
||||||
.appendTo(label);
|
.appendTo(label);
|
||||||
|
|
||||||
label.append(layer.options.name);
|
label.append(layer.options.name);
|
||||||
|
|
||||||
item.on('click', function() {
|
item.on("click", function() {
|
||||||
layers.forEach(function(other) {
|
layers.forEach(function(other) {
|
||||||
if (other === layer) {
|
if (other === layer) {
|
||||||
map.addLayer(other);
|
map.addLayer(other);
|
||||||
|
@ -98,85 +98,85 @@ L.OSM.layers = function(options) {
|
||||||
map.removeLayer(other);
|
map.removeLayer(other);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
map.fire('baselayerchange', {layer: layer});
|
map.fire("baselayerchange", {layer: layer});
|
||||||
});
|
});
|
||||||
|
|
||||||
item.on('dblclick', toggle);
|
item.on("dblclick", toggle);
|
||||||
|
|
||||||
map.on('layeradd layerremove', function() {
|
map.on("layeradd layerremove", function() {
|
||||||
item.toggleClass('active', map.hasLayer(layer));
|
item.toggleClass("active", map.hasLayer(layer));
|
||||||
input.prop('checked', map.hasLayer(layer));
|
input.prop("checked", map.hasLayer(layer));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (OSM.STATUS !== 'api_offline' && OSM.STATUS !== 'database_offline') {
|
if (OSM.STATUS !== "api_offline" && OSM.STATUS !== "database_offline") {
|
||||||
var overlaySection = $('<div>')
|
var overlaySection = $("<div>")
|
||||||
.attr('class', 'section overlay-layers')
|
.attr("class", "section overlay-layers")
|
||||||
.appendTo($ui);
|
.appendTo($ui);
|
||||||
|
|
||||||
$('<p>')
|
$("<p>")
|
||||||
.text(I18n.t('javascripts.map.layers.overlays'))
|
.text(I18n.t("javascripts.map.layers.overlays"))
|
||||||
.attr("class", "deemphasize")
|
.attr("class", "deemphasize")
|
||||||
.appendTo(overlaySection);
|
.appendTo(overlaySection);
|
||||||
|
|
||||||
var overlays = $('<ul>')
|
var overlays = $("<ul>")
|
||||||
.appendTo(overlaySection);
|
.appendTo(overlaySection);
|
||||||
|
|
||||||
var addOverlay = function (layer, name, maxArea) {
|
var addOverlay = function (layer, name, maxArea) {
|
||||||
var item = $('<li>')
|
var item = $("<li>")
|
||||||
.tooltip({
|
.tooltip({
|
||||||
placement: 'top'
|
placement: "top"
|
||||||
})
|
})
|
||||||
.appendTo(overlays);
|
.appendTo(overlays);
|
||||||
|
|
||||||
var label = $('<label>')
|
var label = $("<label>")
|
||||||
.appendTo(item);
|
.appendTo(item);
|
||||||
|
|
||||||
var checked = map.hasLayer(layer);
|
var checked = map.hasLayer(layer);
|
||||||
|
|
||||||
var input = $('<input>')
|
var input = $("<input>")
|
||||||
.attr('type', 'checkbox')
|
.attr("type", "checkbox")
|
||||||
.prop('checked', checked)
|
.prop("checked", checked)
|
||||||
.appendTo(label);
|
.appendTo(label);
|
||||||
|
|
||||||
label.append(I18n.t('javascripts.map.layers.' + name));
|
label.append(I18n.t("javascripts.map.layers." + name));
|
||||||
|
|
||||||
input.on('change', function() {
|
input.on("change", function() {
|
||||||
checked = input.is(':checked');
|
checked = input.is(":checked");
|
||||||
if (checked) {
|
if (checked) {
|
||||||
map.addLayer(layer);
|
map.addLayer(layer);
|
||||||
} else {
|
} else {
|
||||||
map.removeLayer(layer);
|
map.removeLayer(layer);
|
||||||
}
|
}
|
||||||
map.fire('overlaylayerchange', {layer: layer});
|
map.fire("overlaylayerchange", {layer: layer});
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('layeradd layerremove', function() {
|
map.on("layeradd layerremove", function() {
|
||||||
input.prop('checked', map.hasLayer(layer));
|
input.prop("checked", map.hasLayer(layer));
|
||||||
});
|
});
|
||||||
|
|
||||||
map.on('zoomend', function() {
|
map.on("zoomend", function() {
|
||||||
var disabled = map.getBounds().getSize() >= maxArea;
|
var disabled = map.getBounds().getSize() >= maxArea;
|
||||||
$(input).prop('disabled', disabled);
|
$(input).prop("disabled", disabled);
|
||||||
|
|
||||||
if (disabled && $(input).is(':checked')) {
|
if (disabled && $(input).is(":checked")) {
|
||||||
$(input).prop('checked', false)
|
$(input).prop("checked", false)
|
||||||
.trigger('change');
|
.trigger("change");
|
||||||
checked = true;
|
checked = true;
|
||||||
} else if (!disabled && !$(input).is(':checked') && checked) {
|
} else if (!disabled && !$(input).is(":checked") && checked) {
|
||||||
$(input).prop('checked', true)
|
$(input).prop("checked", true)
|
||||||
.trigger('change');
|
.trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
$(item).attr('class', disabled ? 'disabled' : '');
|
$(item).attr("class", disabled ? "disabled" : "");
|
||||||
item.attr('data-original-title', disabled ?
|
item.attr("data-original-title", disabled ?
|
||||||
I18n.t('javascripts.site.map_' + name + '_zoom_in_tooltip') : '');
|
I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip") : "");
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
addOverlay(map.noteLayer, 'notes', OSM.MAX_NOTE_REQUEST_AREA);
|
addOverlay(map.noteLayer, "notes", OSM.MAX_NOTE_REQUEST_AREA);
|
||||||
addOverlay(map.dataLayer, 'data', OSM.MAX_REQUEST_AREA);
|
addOverlay(map.dataLayer, "data", OSM.MAX_REQUEST_AREA);
|
||||||
addOverlay(map.gpsLayer, 'gps', Number.POSITIVE_INFINITY);
|
addOverlay(map.gpsLayer, "gps", Number.POSITIVE_INFINITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
options.sidebar.addPane($ui);
|
options.sidebar.addPane($ui);
|
||||||
|
@ -185,7 +185,7 @@ L.OSM.layers = function(options) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
options.sidebar.togglePane($ui, button);
|
options.sidebar.togglePane($ui, button);
|
||||||
$('.leaflet-control .control-button').tooltip('hide');
|
$(".leaflet-control .control-button").tooltip("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $container[0];
|
return $container[0];
|
||||||
|
|
|
@ -13,8 +13,8 @@ L.OSM.Map = L.Map.extend({
|
||||||
initialize: function(id, options) {
|
initialize: function(id, options) {
|
||||||
L.Map.prototype.initialize.call(this, id, options);
|
L.Map.prototype.initialize.call(this, id, options);
|
||||||
|
|
||||||
var copyright = I18n.t('javascripts.map.copyright', {copyright_url: '/copyright'});
|
var copyright = I18n.t("javascripts.map.copyright", {copyright_url: "/copyright"});
|
||||||
var donate = I18n.t('javascripts.map.donate_link_text', {donate_url: 'https://donate.openstreetmap.org'});
|
var donate = I18n.t("javascripts.map.donate_link_text", {donate_url: "https://donate.openstreetmap.org"});
|
||||||
|
|
||||||
this.baseLayers = [];
|
this.baseLayers = [];
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ L.OSM.Map = L.Map.extend({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.noteLayer = new L.FeatureGroup();
|
this.noteLayer = new L.FeatureGroup();
|
||||||
this.noteLayer.options = {code: 'N'};
|
this.noteLayer.options = {code: "N"};
|
||||||
|
|
||||||
this.dataLayer = new L.OSM.DataLayer(null);
|
this.dataLayer = new L.OSM.DataLayer(null);
|
||||||
this.dataLayer.options.code = 'D';
|
this.dataLayer.options.code = "D";
|
||||||
|
|
||||||
this.gpsLayer = new L.OSM.GPS({
|
this.gpsLayer = new L.OSM.GPS({
|
||||||
pane: "overlayPane",
|
pane: "overlayPane",
|
||||||
|
@ -86,7 +86,7 @@ L.OSM.Map = L.Map.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getLayersCode: function () {
|
getLayersCode: function () {
|
||||||
var layerConfig = '';
|
var layerConfig = "";
|
||||||
this.eachLayer(function (layer) {
|
this.eachLayer(function (layer) {
|
||||||
if (layer.options && layer.options.code) {
|
if (layer.options && layer.options.code) {
|
||||||
layerConfig += layer.options.code;
|
layerConfig += layer.options.code;
|
||||||
|
@ -113,11 +113,11 @@ L.OSM.Map = L.Map.extend({
|
||||||
params.mlon = latLng.lng.toFixed(precision);
|
params.mlon = latLng.lng.toFixed(precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = window.location.protocol + '//' + OSM.SERVER_URL + '/',
|
var url = window.location.protocol + "//" + OSM.SERVER_URL + "/",
|
||||||
query = querystring.stringify(params),
|
query = querystring.stringify(params),
|
||||||
hash = OSM.formatHash(this);
|
hash = OSM.formatHash(this);
|
||||||
|
|
||||||
if (query) url += '?' + query;
|
if (query) url += "?" + query;
|
||||||
if (hash) url += hash;
|
if (hash) url += hash;
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
|
@ -127,8 +127,8 @@ L.OSM.Map = L.Map.extend({
|
||||||
var zoom = this.getZoom(),
|
var zoom = this.getZoom(),
|
||||||
latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
|
latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
|
||||||
str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
|
str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
|
||||||
window.location.protocol + '//osm.org/go/' :
|
window.location.protocol + "//osm.org/go/" :
|
||||||
window.location.protocol + '//' + window.location.hostname + '/go/',
|
window.location.protocol + "//" + window.location.hostname + "/go/",
|
||||||
char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~",
|
char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~",
|
||||||
x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)),
|
x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)),
|
||||||
y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)),
|
y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)),
|
||||||
|
@ -162,14 +162,14 @@ L.OSM.Map = L.Map.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
var params = {};
|
var params = {};
|
||||||
var layers = this.getLayersCode().replace('M', '');
|
var layers = this.getLayersCode().replace("M", "");
|
||||||
|
|
||||||
if (layers) {
|
if (layers) {
|
||||||
params.layers = layers;
|
params.layers = layers;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marker && this.hasLayer(marker)) {
|
if (marker && this.hasLayer(marker)) {
|
||||||
params.m = '';
|
params.m = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._object) {
|
if (this._object) {
|
||||||
|
@ -178,7 +178,7 @@ L.OSM.Map = L.Map.extend({
|
||||||
|
|
||||||
var query = querystring.stringify(params);
|
var query = querystring.stringify(params);
|
||||||
if (query) {
|
if (query) {
|
||||||
str += '?' + query;
|
str += "?" + query;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
|
@ -199,7 +199,7 @@ L.OSM.Map = L.Map.extend({
|
||||||
params.lon = latLng.lng.toFixed(precision);
|
params.lon = latLng.lng.toFixed(precision);
|
||||||
params.zoom = this.getZoom();
|
params.zoom = this.getZoom();
|
||||||
|
|
||||||
return 'geo:' + params.lat + ',' + params.lon + '?z=' + params.zoom;
|
return "geo:" + params.lat + "," + params.lon + "?z=" + params.zoom;
|
||||||
},
|
},
|
||||||
|
|
||||||
addObject: function(object, callback) {
|
addObject: function(object, callback) {
|
||||||
|
@ -212,7 +212,7 @@ L.OSM.Map = L.Map.extend({
|
||||||
|
|
||||||
var changesetStyle = {
|
var changesetStyle = {
|
||||||
weight: 4,
|
weight: 4,
|
||||||
color: '#FF9500',
|
color: "#FF9500",
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
fillOpacity: 0,
|
fillOpacity: 0,
|
||||||
interactive: false
|
interactive: false
|
||||||
|
|
|
@ -2,24 +2,24 @@ L.OSM.note = function (options) {
|
||||||
var control = L.control(options);
|
var control = L.control(options);
|
||||||
|
|
||||||
control.onAdd = function (map) {
|
control.onAdd = function (map) {
|
||||||
var $container = $('<div>')
|
var $container = $("<div>")
|
||||||
.attr('class', 'control-note');
|
.attr("class", "control-note");
|
||||||
|
|
||||||
var link = $('<a>')
|
var link = $("<a>")
|
||||||
.attr('class', 'control-button')
|
.attr("class", "control-button")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.html('<span class="icon note"></span>')
|
.html("<span class=\"icon note\"></span>")
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
|
|
||||||
map.on('zoomend', update);
|
map.on("zoomend", update);
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
|
var disabled = OSM.STATUS === "database_offline" || map.getZoom() < 12;
|
||||||
link
|
link
|
||||||
.toggleClass('disabled', disabled)
|
.toggleClass("disabled", disabled)
|
||||||
.attr('data-original-title', I18n.t(disabled ?
|
.attr("data-original-title", I18n.t(disabled ?
|
||||||
'javascripts.site.createnote_disabled_tooltip' :
|
"javascripts.site.createnote_disabled_tooltip" :
|
||||||
'javascripts.site.createnote_tooltip'));
|
"javascripts.site.createnote_tooltip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -2,32 +2,32 @@ L.OSM.query = function (options) {
|
||||||
var control = L.control(options);
|
var control = L.control(options);
|
||||||
|
|
||||||
control.onAdd = function (map) {
|
control.onAdd = function (map) {
|
||||||
var $container = $('<div>')
|
var $container = $("<div>")
|
||||||
.attr('class', 'control-query');
|
.attr("class", "control-query");
|
||||||
|
|
||||||
var link = $('<a>')
|
var link = $("<a>")
|
||||||
.attr('class', 'control-button')
|
.attr("class", "control-button")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.html('<span class="icon query"></span>')
|
.html("<span class=\"icon query\"></span>")
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
|
|
||||||
map.on('zoomend', update);
|
map.on("zoomend", update);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
var wasDisabled = link.hasClass('disabled'),
|
var wasDisabled = link.hasClass("disabled"),
|
||||||
isDisabled = map.getZoom() < 14;
|
isDisabled = map.getZoom() < 14;
|
||||||
link
|
link
|
||||||
.toggleClass('disabled', isDisabled)
|
.toggleClass("disabled", isDisabled)
|
||||||
.attr('data-original-title', I18n.t(isDisabled ?
|
.attr("data-original-title", I18n.t(isDisabled ?
|
||||||
'javascripts.site.queryfeature_disabled_tooltip' :
|
"javascripts.site.queryfeature_disabled_tooltip" :
|
||||||
'javascripts.site.queryfeature_tooltip'));
|
"javascripts.site.queryfeature_tooltip"));
|
||||||
|
|
||||||
if (isDisabled && !wasDisabled) {
|
if (isDisabled && !wasDisabled) {
|
||||||
link.trigger('disabled');
|
link.trigger("disabled");
|
||||||
} else if (wasDisabled && !isDisabled) {
|
} else if (wasDisabled && !isDisabled) {
|
||||||
link.trigger('enabled');
|
link.trigger("enabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,243 +7,243 @@ L.OSM.share = function (options) {
|
||||||
});
|
});
|
||||||
|
|
||||||
control.onAdd = function (map) {
|
control.onAdd = function (map) {
|
||||||
var $container = $('<div>')
|
var $container = $("<div>")
|
||||||
.attr('class', 'control-share');
|
.attr("class", "control-share");
|
||||||
|
|
||||||
var button = $('<a>')
|
var button = $("<a>")
|
||||||
.attr('class', 'control-button')
|
.attr("class", "control-button")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.attr('title', I18n.t('javascripts.share.title'))
|
.attr("title", I18n.t("javascripts.share.title"))
|
||||||
.html('<span class="icon share"></span>')
|
.html("<span class=\"icon share\"></span>")
|
||||||
.on('click', toggle)
|
.on("click", toggle)
|
||||||
.appendTo($container);
|
.appendTo($container);
|
||||||
|
|
||||||
var $ui = $('<div>')
|
var $ui = $("<div>")
|
||||||
.attr('class', 'share-ui');
|
.attr("class", "share-ui");
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'sidebar_heading')
|
.attr("class", "sidebar_heading")
|
||||||
.appendTo($ui)
|
.appendTo($ui)
|
||||||
.append(
|
.append(
|
||||||
$('<span>')
|
$("<span>")
|
||||||
.text(I18n.t('javascripts.close'))
|
.text(I18n.t("javascripts.close"))
|
||||||
.attr('class', 'icon close')
|
.attr("class", "icon close")
|
||||||
.bind('click', toggle))
|
.bind("click", toggle))
|
||||||
.append(
|
.append(
|
||||||
$('<h4>')
|
$("<h4>")
|
||||||
.text(I18n.t('javascripts.share.title')));
|
.text(I18n.t("javascripts.share.title")));
|
||||||
|
|
||||||
// Link / Embed
|
// Link / Embed
|
||||||
|
|
||||||
var $linkSection = $('<div>')
|
var $linkSection = $("<div>")
|
||||||
.attr('class', 'section share-link')
|
.attr("class", "section share-link")
|
||||||
.appendTo($ui);
|
.appendTo($ui);
|
||||||
|
|
||||||
$('<h4>')
|
$("<h4>")
|
||||||
.text(I18n.t('javascripts.share.link'))
|
.text(I18n.t("javascripts.share.link"))
|
||||||
.appendTo($linkSection);
|
.appendTo($linkSection);
|
||||||
|
|
||||||
var $form = $('<form>')
|
var $form = $("<form>")
|
||||||
.attr('class', 'standard-form')
|
.attr("class", "standard-form")
|
||||||
.appendTo($linkSection);
|
.appendTo($linkSection);
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'form-row')
|
.attr("class", "form-row")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append(
|
.append(
|
||||||
$('<label>')
|
$("<label>")
|
||||||
.attr('for', 'link_marker')
|
.attr("for", "link_marker")
|
||||||
.append(
|
.append(
|
||||||
$('<input>')
|
$("<input>")
|
||||||
.attr('id', 'link_marker')
|
.attr("id", "link_marker")
|
||||||
.attr('type', 'checkbox')
|
.attr("type", "checkbox")
|
||||||
.bind('change', toggleMarker))
|
.bind("change", toggleMarker))
|
||||||
.append(I18n.t('javascripts.share.include_marker')));
|
.append(I18n.t("javascripts.share.include_marker")));
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'share-tabs')
|
.attr("class", "share-tabs")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append($('<a>')
|
.append($("<a>")
|
||||||
.attr('class', 'active')
|
.attr("class", "active")
|
||||||
.attr('for', 'long_input')
|
.attr("for", "long_input")
|
||||||
.attr('id', 'long_link')
|
.attr("id", "long_link")
|
||||||
.text(I18n.t('javascripts.share.long_link')))
|
.text(I18n.t("javascripts.share.long_link")))
|
||||||
.append($('<a>')
|
.append($("<a>")
|
||||||
.attr('for', 'short_input')
|
.attr("for", "short_input")
|
||||||
.attr('id', 'short_link')
|
.attr("id", "short_link")
|
||||||
.text(I18n.t('javascripts.share.short_link')))
|
.text(I18n.t("javascripts.share.short_link")))
|
||||||
.append($('<a>')
|
.append($("<a>")
|
||||||
.attr('for', 'embed_html')
|
.attr("for", "embed_html")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.text(I18n.t('javascripts.share.embed')))
|
.text(I18n.t("javascripts.share.embed")))
|
||||||
.on('click', 'a', function(e) {
|
.on("click", "a", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var id = '#' + $(this).attr('for');
|
var id = "#" + $(this).attr("for");
|
||||||
$linkSection.find('.share-tabs a')
|
$linkSection.find(".share-tabs a")
|
||||||
.removeClass('active');
|
.removeClass("active");
|
||||||
$(this).addClass('active');
|
$(this).addClass("active");
|
||||||
$linkSection.find('.share-tab')
|
$linkSection.find(".share-tab")
|
||||||
.hide();
|
.hide();
|
||||||
$linkSection.find('.share-tab:has(' + id + ')')
|
$linkSection.find(".share-tab:has(" + id + ")")
|
||||||
.show()
|
.show()
|
||||||
.find('input, textarea')
|
.find("input, textarea")
|
||||||
.select();
|
.select();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'form-row share-tab')
|
.attr("class", "form-row share-tab")
|
||||||
.css('display', 'block')
|
.css("display", "block")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append($('<input>')
|
.append($("<input>")
|
||||||
.attr('id', 'long_input')
|
.attr("id", "long_input")
|
||||||
.attr('type', 'text')
|
.attr("type", "text")
|
||||||
.on('click', select));
|
.on("click", select));
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'form-row share-tab')
|
.attr("class", "form-row share-tab")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append($('<input>')
|
.append($("<input>")
|
||||||
.attr('id', 'short_input')
|
.attr("id", "short_input")
|
||||||
.attr('type', 'text')
|
.attr("type", "text")
|
||||||
.on('click', select));
|
.on("click", select));
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'form-row share-tab')
|
.attr("class", "form-row share-tab")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append(
|
.append(
|
||||||
$('<textarea>')
|
$("<textarea>")
|
||||||
.attr('id', 'embed_html')
|
.attr("id", "embed_html")
|
||||||
.on('click', select))
|
.on("click", select))
|
||||||
.append(
|
.append(
|
||||||
$('<p>')
|
$("<p>")
|
||||||
.attr('class', 'deemphasize')
|
.attr("class", "deemphasize")
|
||||||
.text(I18n.t('javascripts.share.paste_html'))
|
.text(I18n.t("javascripts.share.paste_html"))
|
||||||
.appendTo($linkSection));
|
.appendTo($linkSection));
|
||||||
|
|
||||||
// Geo URI
|
// Geo URI
|
||||||
|
|
||||||
var $geoUriSection = $('<div>')
|
var $geoUriSection = $("<div>")
|
||||||
.attr('class', 'section share-geo-uri')
|
.attr("class", "section share-geo-uri")
|
||||||
.appendTo($ui);
|
.appendTo($ui);
|
||||||
|
|
||||||
$('<h4>')
|
$("<h4>")
|
||||||
.text(I18n.t('javascripts.share.geo_uri'))
|
.text(I18n.t("javascripts.share.geo_uri"))
|
||||||
.appendTo($geoUriSection);
|
.appendTo($geoUriSection);
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.appendTo($geoUriSection)
|
.appendTo($geoUriSection)
|
||||||
.append($('<a>')
|
.append($("<a>")
|
||||||
.attr('id', 'geo_uri'));
|
.attr("id", "geo_uri"));
|
||||||
|
|
||||||
// Image
|
// Image
|
||||||
|
|
||||||
var $imageSection = $('<div>')
|
var $imageSection = $("<div>")
|
||||||
.attr('class', 'section share-image')
|
.attr("class", "section share-image")
|
||||||
.appendTo($ui);
|
.appendTo($ui);
|
||||||
|
|
||||||
$('<h4>')
|
$("<h4>")
|
||||||
.text(I18n.t('javascripts.share.image'))
|
.text(I18n.t("javascripts.share.image"))
|
||||||
.appendTo($imageSection);
|
.appendTo($imageSection);
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('id', 'export-warning')
|
.attr("id", "export-warning")
|
||||||
.attr('class', 'deemphasize')
|
.attr("class", "deemphasize")
|
||||||
.text(I18n.t('javascripts.share.only_standard_layer'))
|
.text(I18n.t("javascripts.share.only_standard_layer"))
|
||||||
.appendTo($imageSection);
|
.appendTo($imageSection);
|
||||||
|
|
||||||
$form = $('<form>')
|
$form = $("<form>")
|
||||||
.attr('id', 'export-image')
|
.attr("id", "export-image")
|
||||||
.attr('class', 'standard-form')
|
.attr("class", "standard-form")
|
||||||
.attr('action', '/export/finish')
|
.attr("action", "/export/finish")
|
||||||
.attr('method', 'post')
|
.attr("method", "post")
|
||||||
.appendTo($imageSection);
|
.appendTo($imageSection);
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'form-row')
|
.attr("class", "form-row")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append(
|
.append(
|
||||||
$('<label>')
|
$("<label>")
|
||||||
.attr('for', 'image_filter')
|
.attr("for", "image_filter")
|
||||||
.append(
|
.append(
|
||||||
$('<input>')
|
$("<input>")
|
||||||
.attr('id', 'image_filter')
|
.attr("id", "image_filter")
|
||||||
.attr('type', 'checkbox')
|
.attr("type", "checkbox")
|
||||||
.bind('change', toggleFilter))
|
.bind("change", toggleFilter))
|
||||||
.append(I18n.t('javascripts.share.custom_dimensions')));
|
.append(I18n.t("javascripts.share.custom_dimensions")));
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'form-row')
|
.attr("class", "form-row")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append(
|
.append(
|
||||||
$('<label>')
|
$("<label>")
|
||||||
.attr('for', 'mapnik_format')
|
.attr("for", "mapnik_format")
|
||||||
.text(I18n.t('javascripts.share.format')))
|
.text(I18n.t("javascripts.share.format")))
|
||||||
.append($('<select>')
|
.append($("<select>")
|
||||||
.attr('name', 'mapnik_format')
|
.attr("name", "mapnik_format")
|
||||||
.attr('id', 'mapnik_format')
|
.attr("id", "mapnik_format")
|
||||||
.append($('<option>').val('png').text('PNG').prop('selected', true))
|
.append($("<option>").val("png").text("PNG").prop("selected", true))
|
||||||
.append($('<option>').val('jpeg').text('JPEG'))
|
.append($("<option>").val("jpeg").text("JPEG"))
|
||||||
.append($('<option>').val('svg').text('SVG'))
|
.append($("<option>").val("svg").text("SVG"))
|
||||||
.append($('<option>').val('pdf').text('PDF')));
|
.append($("<option>").val("pdf").text("PDF")));
|
||||||
|
|
||||||
$('<div>')
|
$("<div>")
|
||||||
.attr('class', 'form-row')
|
.attr("class", "form-row")
|
||||||
.appendTo($form)
|
.appendTo($form)
|
||||||
.append($('<label>')
|
.append($("<label>")
|
||||||
.attr('for', 'mapnik_scale')
|
.attr("for", "mapnik_scale")
|
||||||
.text(I18n.t('javascripts.share.scale')))
|
.text(I18n.t("javascripts.share.scale")))
|
||||||
.append('1 : ')
|
.append("1 : ")
|
||||||
.append($('<input>')
|
.append($("<input>")
|
||||||
.attr('name', 'mapnik_scale')
|
.attr("name", "mapnik_scale")
|
||||||
.attr('id', 'mapnik_scale')
|
.attr("id", "mapnik_scale")
|
||||||
.attr('type', 'text')
|
.attr("type", "text")
|
||||||
.on('change', update));
|
.on("change", update));
|
||||||
|
|
||||||
['minlon', 'minlat', 'maxlon', 'maxlat'].forEach(function(name) {
|
["minlon", "minlat", "maxlon", "maxlat"].forEach(function(name) {
|
||||||
$('<input>')
|
$("<input>")
|
||||||
.attr('id', 'mapnik_' + name)
|
.attr("id", "mapnik_" + name)
|
||||||
.attr('name', name)
|
.attr("name", name)
|
||||||
.attr('type', 'hidden')
|
.attr("type", "hidden")
|
||||||
.appendTo($form);
|
.appendTo($form);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('<input>')
|
$("<input>")
|
||||||
.attr('name', 'format')
|
.attr("name", "format")
|
||||||
.attr('value', 'mapnik')
|
.attr("value", "mapnik")
|
||||||
.attr('type', 'hidden')
|
.attr("type", "hidden")
|
||||||
.appendTo($form);
|
.appendTo($form);
|
||||||
|
|
||||||
var csrf_param = $("meta[name=csrf-param]").attr("content"),
|
var csrf_param = $("meta[name=csrf-param]").attr("content"),
|
||||||
csrf_token = $("meta[name=csrf-token]").attr("content");
|
csrf_token = $("meta[name=csrf-token]").attr("content");
|
||||||
|
|
||||||
$('<input>')
|
$("<input>")
|
||||||
.attr('name', csrf_param)
|
.attr("name", csrf_param)
|
||||||
.attr('value', csrf_token)
|
.attr("value", csrf_token)
|
||||||
.attr('type', 'hidden')
|
.attr("type", "hidden")
|
||||||
.appendTo($form);
|
.appendTo($form);
|
||||||
|
|
||||||
$('<p>')
|
$("<p>")
|
||||||
.attr('class', 'deemphasize')
|
.attr("class", "deemphasize")
|
||||||
.html(I18n.t('javascripts.share.image_size') + ' <span id="mapnik_image_width"></span> x <span id="mapnik_image_height"></span>')
|
.html(I18n.t("javascripts.share.image_size") + " <span id=\"mapnik_image_width\"></span> x <span id=\"mapnik_image_height\"></span>")
|
||||||
.appendTo($form);
|
.appendTo($form);
|
||||||
|
|
||||||
$('<input>')
|
$("<input>")
|
||||||
.attr('type', 'submit')
|
.attr("type", "submit")
|
||||||
.attr('value', I18n.t('javascripts.share.download'))
|
.attr("value", I18n.t("javascripts.share.download"))
|
||||||
.appendTo($form);
|
.appendTo($form);
|
||||||
|
|
||||||
locationFilter
|
locationFilter
|
||||||
.on('change', update)
|
.on("change", update)
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
marker.on('dragend', movedMarker);
|
marker.on("dragend", movedMarker);
|
||||||
map.on('move', movedMap);
|
map.on("move", movedMap);
|
||||||
map.on('moveend layeradd layerremove', update);
|
map.on("moveend layeradd layerremove", update);
|
||||||
|
|
||||||
options.sidebar.addPane($ui);
|
options.sidebar.addPane($ui);
|
||||||
|
|
||||||
$ui
|
$ui
|
||||||
.on('hide', hidden);
|
.on("hide", hidden);
|
||||||
|
|
||||||
function hidden() {
|
function hidden() {
|
||||||
map.removeLayer(marker);
|
map.removeLayer(marker);
|
||||||
|
@ -256,19 +256,19 @@ L.OSM.share = function (options) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$('#mapnik_scale').val(getScale());
|
$("#mapnik_scale").val(getScale());
|
||||||
marker.setLatLng(map.getCenter());
|
marker.setLatLng(map.getCenter());
|
||||||
|
|
||||||
update();
|
update();
|
||||||
options.sidebar.togglePane($ui, button);
|
options.sidebar.togglePane($ui, button);
|
||||||
$('.leaflet-control .control-button').tooltip('hide');
|
$(".leaflet-control .control-button").tooltip("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMarker() {
|
function toggleMarker() {
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(":checked")) {
|
||||||
marker.setLatLng(map.getCenter());
|
marker.setLatLng(map.getCenter());
|
||||||
map.addLayer(marker);
|
map.addLayer(marker);
|
||||||
map.options.scrollWheelZoom = map.options.doubleClickZoom = 'center';
|
map.options.scrollWheelZoom = map.options.doubleClickZoom = "center";
|
||||||
} else {
|
} else {
|
||||||
map.removeLayer(marker);
|
map.removeLayer(marker);
|
||||||
map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
|
map.options.scrollWheelZoom = map.options.doubleClickZoom = true;
|
||||||
|
@ -277,7 +277,7 @@ L.OSM.share = function (options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleFilter() {
|
function toggleFilter() {
|
||||||
if ($(this).is(':checked')) {
|
if ($(this).is(":checked")) {
|
||||||
locationFilter.setBounds(map.getBounds().pad(-0.2));
|
locationFilter.setBounds(map.getBounds().pad(-0.2));
|
||||||
locationFilter.enable();
|
locationFilter.enable();
|
||||||
} else {
|
} else {
|
||||||
|
@ -293,27 +293,27 @@ L.OSM.share = function (options) {
|
||||||
|
|
||||||
function movedMarker() {
|
function movedMarker() {
|
||||||
if (map.hasLayer(marker)) {
|
if (map.hasLayer(marker)) {
|
||||||
map.off('move', movedMap);
|
map.off("move", movedMap);
|
||||||
map.on('moveend', updateOnce);
|
map.on("moveend", updateOnce);
|
||||||
map.panTo(marker.getLatLng());
|
map.panTo(marker.getLatLng());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOnce() {
|
function updateOnce() {
|
||||||
map.off('moveend', updateOnce);
|
map.off("moveend", updateOnce);
|
||||||
map.on('move', movedMap);
|
map.on("move", movedMap);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeHTML(string) {
|
function escapeHTML(string) {
|
||||||
var htmlEscapes = {
|
var htmlEscapes = {
|
||||||
'&': '&',
|
"&": "&",
|
||||||
'<': '<',
|
"<": "<",
|
||||||
'>': '>',
|
">": ">",
|
||||||
'"': '"',
|
"\"": """,
|
||||||
"'": '''
|
"'": "'"
|
||||||
};
|
};
|
||||||
return string === null ? '' : (string + '').replace(/[&<>"']/g, function(match) {
|
return string === null ? "" : (string + "").replace(/[&<>"']/g, function(match) {
|
||||||
return htmlEscapes[match];
|
return htmlEscapes[match];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -321,18 +321,18 @@ L.OSM.share = function (options) {
|
||||||
function update() {
|
function update() {
|
||||||
var bounds = map.getBounds();
|
var bounds = map.getBounds();
|
||||||
|
|
||||||
$('#link_marker')
|
$("#link_marker")
|
||||||
.prop('checked', map.hasLayer(marker));
|
.prop("checked", map.hasLayer(marker));
|
||||||
|
|
||||||
$('#image_filter')
|
$("#image_filter")
|
||||||
.prop('checked', locationFilter.isEnabled());
|
.prop("checked", locationFilter.isEnabled());
|
||||||
|
|
||||||
// Link / Embed
|
// Link / Embed
|
||||||
|
|
||||||
$('#short_input').val(map.getShortUrl(marker));
|
$("#short_input").val(map.getShortUrl(marker));
|
||||||
$('#long_input').val(map.getUrl(marker));
|
$("#long_input").val(map.getUrl(marker));
|
||||||
$('#short_link').attr('href', map.getShortUrl(marker));
|
$("#short_link").attr("href", map.getShortUrl(marker));
|
||||||
$('#long_link').attr('href', map.getUrl(marker));
|
$("#long_link").attr("href", map.getUrl(marker));
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
bbox: bounds.toBBoxString(),
|
bbox: bounds.toBBoxString(),
|
||||||
|
@ -341,20 +341,20 @@ L.OSM.share = function (options) {
|
||||||
|
|
||||||
if (map.hasLayer(marker)) {
|
if (map.hasLayer(marker)) {
|
||||||
var latLng = marker.getLatLng().wrap();
|
var latLng = marker.getLatLng().wrap();
|
||||||
params.marker = latLng.lat + ',' + latLng.lng;
|
params.marker = latLng.lat + "," + latLng.lng;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#embed_html').val(
|
$("#embed_html").val(
|
||||||
'<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' +
|
"<iframe width=\"425\" height=\"350\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"" +
|
||||||
escapeHTML(OSM.SERVER_PROTOCOL + '://' + OSM.SERVER_URL + '/export/embed.html?' + $.param(params)) +
|
escapeHTML(OSM.SERVER_PROTOCOL + "://" + OSM.SERVER_URL + "/export/embed.html?" + $.param(params)) +
|
||||||
'" style="border: 1px solid black"></iframe><br/>' +
|
"\" style=\"border: 1px solid black\"></iframe><br/>" +
|
||||||
'<small><a href="' + escapeHTML(map.getUrl(marker)) + '">' +
|
"<small><a href=\"" + escapeHTML(map.getUrl(marker)) + "\">" +
|
||||||
escapeHTML(I18n.t('javascripts.share.view_larger_map')) + '</a></small>');
|
escapeHTML(I18n.t("javascripts.share.view_larger_map")) + "</a></small>");
|
||||||
|
|
||||||
// Geo URI
|
// Geo URI
|
||||||
|
|
||||||
$('#geo_uri')
|
$("#geo_uri")
|
||||||
.attr('href', map.getGeoUri(marker))
|
.attr("href", map.getGeoUri(marker))
|
||||||
.html(map.getGeoUri(marker));
|
.html(map.getGeoUri(marker));
|
||||||
|
|
||||||
// Image
|
// Image
|
||||||
|
@ -368,10 +368,10 @@ L.OSM.share = function (options) {
|
||||||
L.CRS.EPSG3857.project(bounds.getNorthEast())).getSize(),
|
L.CRS.EPSG3857.project(bounds.getNorthEast())).getSize(),
|
||||||
maxScale = Math.floor(Math.sqrt(size.x * size.y / 0.3136));
|
maxScale = Math.floor(Math.sqrt(size.x * size.y / 0.3136));
|
||||||
|
|
||||||
$('#mapnik_minlon').val(bounds.getWest());
|
$("#mapnik_minlon").val(bounds.getWest());
|
||||||
$('#mapnik_minlat').val(bounds.getSouth());
|
$("#mapnik_minlat").val(bounds.getSouth());
|
||||||
$('#mapnik_maxlon').val(bounds.getEast());
|
$("#mapnik_maxlon").val(bounds.getEast());
|
||||||
$('#mapnik_maxlat').val(bounds.getNorth());
|
$("#mapnik_maxlat").val(bounds.getNorth());
|
||||||
|
|
||||||
if (scale < maxScale) {
|
if (scale < maxScale) {
|
||||||
scale = roundScale(maxScale);
|
scale = roundScale(maxScale);
|
||||||
|
@ -381,12 +381,12 @@ L.OSM.share = function (options) {
|
||||||
$("#mapnik_image_width").text(Math.round(size.x / scale / 0.00028));
|
$("#mapnik_image_width").text(Math.round(size.x / scale / 0.00028));
|
||||||
$("#mapnik_image_height").text(Math.round(size.y / scale / 0.00028));
|
$("#mapnik_image_height").text(Math.round(size.y / scale / 0.00028));
|
||||||
|
|
||||||
if (map.getMapBaseLayerId() === 'mapnik') {
|
if (map.getMapBaseLayerId() === "mapnik") {
|
||||||
$('#export-image').show();
|
$("#export-image").show();
|
||||||
$('#export-warning').hide();
|
$("#export-warning").hide();
|
||||||
} else {
|
} else {
|
||||||
$('#export-image').hide();
|
$("#export-image").hide();
|
||||||
$('#export-warning').show();
|
$("#export-warning").show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,10 @@ L.OSM.sidebar = function(selector) {
|
||||||
control.togglePane = function(pane, button) {
|
control.togglePane = function(pane, button) {
|
||||||
current
|
current
|
||||||
.hide()
|
.hide()
|
||||||
.trigger('hide');
|
.trigger("hide");
|
||||||
|
|
||||||
currentButton
|
currentButton
|
||||||
.removeClass('active');
|
.removeClass("active");
|
||||||
|
|
||||||
if (current === pane) {
|
if (current === pane) {
|
||||||
$(sidebar).hide();
|
$(sidebar).hide();
|
||||||
|
@ -37,10 +37,10 @@ L.OSM.sidebar = function(selector) {
|
||||||
|
|
||||||
current
|
current
|
||||||
.show()
|
.show()
|
||||||
.trigger('show');
|
.trigger("show");
|
||||||
|
|
||||||
currentButton
|
currentButton
|
||||||
.addClass('active');
|
.addClass("active");
|
||||||
};
|
};
|
||||||
|
|
||||||
return control;
|
return control;
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
L.OSM.Zoom = L.Control.extend({
|
L.OSM.Zoom = L.Control.extend({
|
||||||
options: {
|
options: {
|
||||||
position: 'topright'
|
position: "topright"
|
||||||
},
|
},
|
||||||
|
|
||||||
onAdd: function (map) {
|
onAdd: function (map) {
|
||||||
var zoomName = 'zoom',
|
var zoomName = "zoom",
|
||||||
container = L.DomUtil.create('div', zoomName);
|
container = L.DomUtil.create("div", zoomName);
|
||||||
|
|
||||||
this._map = map;
|
this._map = map;
|
||||||
|
|
||||||
this._zoomInButton = this._createButton(
|
this._zoomInButton = this._createButton(
|
||||||
'', I18n.t('javascripts.map.zoom.in'), zoomName + 'in', container, this._zoomIn, this);
|
"", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
|
||||||
this._zoomOutButton = this._createButton(
|
this._zoomOutButton = this._createButton(
|
||||||
'', I18n.t('javascripts.map.zoom.out'), zoomName + 'out', container, this._zoomOut, this);
|
"", I18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this);
|
||||||
|
|
||||||
map.on('zoomend zoomlevelschange', this._updateDisabled, this);
|
map.on("zoomend zoomlevelschange", this._updateDisabled, this);
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function (map) {
|
onRemove: function (map) {
|
||||||
map.off('zoomend zoomlevelschange', this._updateDisabled, this);
|
map.off("zoomend zoomlevelschange", this._updateDisabled, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
_zoomIn: function (e) {
|
_zoomIn: function (e) {
|
||||||
|
@ -32,28 +32,28 @@ L.OSM.Zoom = L.Control.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_createButton: function (html, title, className, container, fn, context) {
|
_createButton: function (html, title, className, container, fn, context) {
|
||||||
var link = L.DomUtil.create('a', 'control-button ' + className, container);
|
var link = L.DomUtil.create("a", "control-button " + className, container);
|
||||||
link.innerHTML = html;
|
link.innerHTML = html;
|
||||||
link.href = '#';
|
link.href = "#";
|
||||||
link.title = title;
|
link.title = title;
|
||||||
|
|
||||||
L.DomUtil.create('span', 'icon ' + className, link);
|
L.DomUtil.create("span", "icon " + className, link);
|
||||||
|
|
||||||
var stop = L.DomEvent.stopPropagation;
|
var stop = L.DomEvent.stopPropagation;
|
||||||
|
|
||||||
L.DomEvent
|
L.DomEvent
|
||||||
.on(link, 'click', stop)
|
.on(link, "click", stop)
|
||||||
.on(link, 'mousedown', stop)
|
.on(link, "mousedown", stop)
|
||||||
.on(link, 'dblclick', stop)
|
.on(link, "dblclick", stop)
|
||||||
.on(link, 'click', L.DomEvent.preventDefault)
|
.on(link, "click", L.DomEvent.preventDefault)
|
||||||
.on(link, 'click', fn, context);
|
.on(link, "click", fn, context);
|
||||||
|
|
||||||
return link;
|
return link;
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateDisabled: function () {
|
_updateDisabled: function () {
|
||||||
var map = this._map,
|
var map = this._map,
|
||||||
className = 'disabled';
|
className = "disabled";
|
||||||
|
|
||||||
L.DomUtil.removeClass(this._zoomInButton, className);
|
L.DomUtil.removeClass(this._zoomInButton, className);
|
||||||
L.DomUtil.removeClass(this._zoomOutButton, className);
|
L.DomUtil.removeClass(this._zoomOutButton, className);
|
||||||
|
|
|
@ -4,7 +4,7 @@ $(document).ready(function () {
|
||||||
var application_data = $("head").data();
|
var application_data = $("head").data();
|
||||||
|
|
||||||
function makeAbsolute(url) {
|
function makeAbsolute(url) {
|
||||||
var a = document.createElement('a');
|
var a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
return a.href;
|
return a.href;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,13 +53,13 @@ OSM.Router = function(map, rts) {
|
||||||
var splatParam = /\*\w+/g;
|
var splatParam = /\*\w+/g;
|
||||||
|
|
||||||
function Route(path, controller) {
|
function Route(path, controller) {
|
||||||
var regexp = new RegExp('^' +
|
var regexp = new RegExp("^" +
|
||||||
path.replace(escapeRegExp, '\\$&')
|
path.replace(escapeRegExp, "\\$&")
|
||||||
.replace(optionalParam, '(?:$1)?')
|
.replace(optionalParam, "(?:$1)?")
|
||||||
.replace(namedParam, function(match, optional){
|
.replace(namedParam, function(match, optional){
|
||||||
return optional ? match : '([^\/]+)';
|
return optional ? match : "([^\/]+)";
|
||||||
})
|
})
|
||||||
.replace(splatParam, '(.*?)') + '(?:\\?.*)?$');
|
.replace(splatParam, "(.*?)") + "(?:\\?.*)?$");
|
||||||
|
|
||||||
var route = {};
|
var route = {};
|
||||||
|
|
||||||
|
@ -94,36 +94,36 @@ OSM.Router = function(map, rts) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var currentPath = window.location.pathname.replace(/(.)\/$/, '$1') + window.location.search,
|
var currentPath = window.location.pathname.replace(/(.)\/$/, "$1") + window.location.search,
|
||||||
currentRoute = routes.recognize(currentPath),
|
currentRoute = routes.recognize(currentPath),
|
||||||
currentHash = location.hash || OSM.formatHash(map);
|
currentHash = location.hash || OSM.formatHash(map);
|
||||||
|
|
||||||
var router = {};
|
var router = {};
|
||||||
|
|
||||||
if (window.history && window.history.pushState) {
|
if (window.history && window.history.pushState) {
|
||||||
$(window).on('popstate', function(e) {
|
$(window).on("popstate", function(e) {
|
||||||
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
|
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
|
||||||
var path = window.location.pathname + window.location.search,
|
var path = window.location.pathname + window.location.search,
|
||||||
route = routes.recognize(path);
|
route = routes.recognize(path);
|
||||||
if (path === currentPath) return;
|
if (path === currentPath) return;
|
||||||
currentRoute.run('unload', null, route === currentRoute);
|
currentRoute.run("unload", null, route === currentRoute);
|
||||||
currentPath = path;
|
currentPath = path;
|
||||||
currentRoute = route;
|
currentRoute = route;
|
||||||
currentRoute.run('popstate', currentPath);
|
currentRoute.run("popstate", currentPath);
|
||||||
map.setState(e.originalEvent.state, {animate: false});
|
map.setState(e.originalEvent.state, {animate: false});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.route = function (url) {
|
router.route = function (url) {
|
||||||
var path = url.replace(/#.*/, ''),
|
var path = url.replace(/#.*/, ""),
|
||||||
route = routes.recognize(path);
|
route = routes.recognize(path);
|
||||||
if (!route) return false;
|
if (!route) return false;
|
||||||
currentRoute.run('unload', null, route === currentRoute);
|
currentRoute.run("unload", null, route === currentRoute);
|
||||||
var state = OSM.parseHash(url);
|
var state = OSM.parseHash(url);
|
||||||
map.setState(state);
|
map.setState(state);
|
||||||
window.history.pushState(state, document.title, url);
|
window.history.pushState(state, document.title, url);
|
||||||
currentPath = path;
|
currentPath = path;
|
||||||
currentRoute = route;
|
currentRoute = route;
|
||||||
currentRoute.run('pushstate', currentPath);
|
currentRoute.run("pushstate", currentPath);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,19 +166,19 @@ OSM.Router = function(map, rts) {
|
||||||
|
|
||||||
router.withoutMoveListener = function (callback) {
|
router.withoutMoveListener = function (callback) {
|
||||||
function disableMoveListener() {
|
function disableMoveListener() {
|
||||||
map.off('moveend', router.updateHash);
|
map.off("moveend", router.updateHash);
|
||||||
map.once('moveend', function () {
|
map.once("moveend", function () {
|
||||||
map.on('moveend', router.updateHash);
|
map.on("moveend", router.updateHash);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
map.once('movestart', disableMoveListener);
|
map.once("movestart", disableMoveListener);
|
||||||
callback();
|
callback();
|
||||||
map.off('movestart', disableMoveListener);
|
map.off("movestart", disableMoveListener);
|
||||||
};
|
};
|
||||||
|
|
||||||
router.load = function() {
|
router.load = function() {
|
||||||
var loadState = currentRoute.run('load', currentPath);
|
var loadState = currentRoute.run("load", currentPath);
|
||||||
router.stateChange(loadState || {});
|
router.stateChange(loadState || {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -187,8 +187,8 @@ OSM.Router = function(map, rts) {
|
||||||
currentRoute = routes.recognize(currentPath);
|
currentRoute = routes.recognize(currentPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
map.on('moveend baselayerchange overlaylayerchange', router.updateHash);
|
map.on("moveend baselayerchange overlaylayerchange", router.updateHash);
|
||||||
$(window).on('hashchange', router.hashUpdated);
|
$(window).on("hashchange", router.hashUpdated);
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,30 +7,30 @@ $(document).ready(function () {
|
||||||
zoomControl: false
|
zoomControl: false
|
||||||
}).addLayer(new L.OSM.Mapnik());
|
}).addLayer(new L.OSM.Mapnik());
|
||||||
|
|
||||||
var position = $('html').attr('dir') === 'rtl' ? 'topleft' : 'topright';
|
var position = $("html").attr("dir") === "rtl" ? "topleft" : "topright";
|
||||||
|
|
||||||
L.OSM.zoom({position: position})
|
L.OSM.zoom({position: position})
|
||||||
.addTo(map);
|
.addTo(map);
|
||||||
|
|
||||||
var locate = L.control.locate({
|
var locate = L.control.locate({
|
||||||
position: position,
|
position: position,
|
||||||
icon: 'icon geolocate',
|
icon: "icon geolocate",
|
||||||
iconLoading: 'icon geolocate',
|
iconLoading: "icon geolocate",
|
||||||
strings: {
|
strings: {
|
||||||
title: I18n.t('javascripts.map.locate.title'),
|
title: I18n.t("javascripts.map.locate.title"),
|
||||||
popup: I18n.t('javascripts.map.locate.popup')
|
popup: I18n.t("javascripts.map.locate.popup")
|
||||||
}
|
}
|
||||||
}).addTo(map);
|
}).addTo(map);
|
||||||
|
|
||||||
var locateContainer = locate.getContainer();
|
var locateContainer = locate.getContainer();
|
||||||
|
|
||||||
$(locateContainer)
|
$(locateContainer)
|
||||||
.removeClass('leaflet-control-locate leaflet-bar')
|
.removeClass("leaflet-control-locate leaflet-bar")
|
||||||
.addClass('control-locate')
|
.addClass("control-locate")
|
||||||
.children("a")
|
.children("a")
|
||||||
.attr('href', '#')
|
.attr("href", "#")
|
||||||
.removeClass('leaflet-bar-part leaflet-bar-part-single')
|
.removeClass("leaflet-bar-part leaflet-bar-part-single")
|
||||||
.addClass('control-button');
|
.addClass("control-button");
|
||||||
|
|
||||||
if (OSM.home) {
|
if (OSM.home) {
|
||||||
map.setView([OSM.home.lat, OSM.home.lon], 12);
|
map.setView([OSM.home.lat, OSM.home.lon], 12);
|
||||||
|
@ -47,14 +47,14 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
map.on("click", function (e) {
|
map.on("click", function (e) {
|
||||||
if ($('#updatehome').is(':checked')) {
|
if ($("#updatehome").is(":checked")) {
|
||||||
var zoom = map.getZoom(),
|
var zoom = map.getZoom(),
|
||||||
precision = OSM.zoomPrecision(zoom),
|
precision = OSM.zoomPrecision(zoom),
|
||||||
location = e.latlng.wrap();
|
location = e.latlng.wrap();
|
||||||
|
|
||||||
$('#homerow').removeClass();
|
$("#homerow").removeClass();
|
||||||
$('#home_lat').val(location.lat.toFixed(precision));
|
$("#home_lat").val(location.lat.toFixed(precision));
|
||||||
$('#home_lon').val(location.lng.toFixed(precision));
|
$("#home_lon").val(location.lng.toFixed(precision));
|
||||||
|
|
||||||
marker.setLatLng(e.latlng);
|
marker.setLatLng(e.latlng);
|
||||||
marker.addTo(map);
|
marker.addTo(map);
|
||||||
|
@ -62,7 +62,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$("[data-user]").each(function () {
|
$("[data-user]").each(function () {
|
||||||
var user = $(this).data('user');
|
var user = $(this).data("user");
|
||||||
if (user.lon && user.lat) {
|
if (user.lon && user.lat) {
|
||||||
L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
|
L.marker([user.lat, user.lon], {icon: OSM.getUserIcon(user.icon)}).addTo(map)
|
||||||
.bindPopup(user.description);
|
.bindPopup(user.description);
|
||||||
|
|
|
@ -6,28 +6,28 @@ $(document).ready(function() {
|
||||||
params.lon = parseFloat(params.lon);
|
params.lon = parseFloat(params.lon);
|
||||||
params.zoom = params.zoom || 17;
|
params.zoom = params.zoom || 17;
|
||||||
|
|
||||||
var url = '/edit';
|
var url = "/edit";
|
||||||
|
|
||||||
if (params.editor) {
|
if (params.editor) {
|
||||||
url += '?editor=' + params.editor;
|
url += "?editor=" + params.editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
url += OSM.formatHash(params);
|
url += OSM.formatHash(params);
|
||||||
|
|
||||||
$('.start-mapping').attr('href', url);
|
$(".start-mapping").attr("href", url);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
var geoSuccess = function (position) {
|
var geoSuccess = function (position) {
|
||||||
window.location = '/edit' + OSM.formatHash({
|
window.location = "/edit" + OSM.formatHash({
|
||||||
zoom: 17,
|
zoom: 17,
|
||||||
lat: position.coords.latitude,
|
lat: position.coords.latitude,
|
||||||
lon: position.coords.longitude
|
lon: position.coords.longitude
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$('.start-mapping').on('click', function(e) {
|
$(".start-mapping").on("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('.start-mapping').addClass('loading');
|
$(".start-mapping").addClass("loading");
|
||||||
|
|
||||||
if (navigator.geolocation) {
|
if (navigator.geolocation) {
|
||||||
// handle firefox's weird implementation
|
// handle firefox's weird implementation
|
||||||
|
@ -42,6 +42,6 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function manualEdit() {
|
function manualEdit() {
|
||||||
window.location = '/?edit_help=1';
|
window.location = "/?edit_help=1";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
"no-void": "error",
|
"no-void": "error",
|
||||||
"no-warning-comments": "warn",
|
"no-warning-comments": "warn",
|
||||||
"no-with": "error",
|
"no-with": "error",
|
||||||
|
"quotes": ["error", "double"],
|
||||||
"radix": ["error", "always"],
|
"radix": ["error", "always"],
|
||||||
"semi": ["error", "always"],
|
"semi": ["error", "always"],
|
||||||
"semi-spacing": "error",
|
"semi-spacing": "error",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue