window.updateLinks = function (loc, zoom, layers, object) {
$(".geolink").each(function (index, link) {
var href = link.href.split(/[?#]/)[0],
- args = qs.parse(link.search.substring(1)),
- editlink = $(link).hasClass("editlink");
+ args = qs.parse(link.search.substring(1)),
+ editlink = $(link).hasClass("editlink");
delete args.node;
delete args.way;
id.map().on("move.embed", parent.$.throttle(250, function () {
if (id.inIntro()) return;
var zoom = ~~id.map().zoom(),
- center = id.map().center(),
- llz = { lon: center[0], lat: center[1], zoom: zoom };
+ center = id.map().center(),
+ llz = { lon: center[0], lat: center[1], zoom: zoom };
parent.updateLinks(llz, zoom);
e.preventDefault();
var data = $(this).data(),
- center = L.latLng(data.lat, data.lon);
+ center = L.latLng(data.lat, data.lon);
map.setView(center, data.zoom);
L.marker(center, { icon: OSM.getUserIcon() }).addTo(map);
if (object) query.select = object.type + object.id;
var iframe = $("<iframe>")
- .hide()
- .appendTo("body")
- .attr("src", url + querystring.stringify(query))
- .on("load", function () {
- $(this).remove();
- loaded = true;
- });
+ .hide()
+ .appendTo("body")
+ .attr("src", url + querystring.stringify(query))
+ .on("load", function () {
+ $(this).remove();
+ loaded = true;
+ });
setTimeout(function () {
if (!loaded) {
OSM.Changeset = function (map) {
var page = {},
- content = $("#sidebar_content"),
- currentChangesetId;
+ content = $("#sidebar_content"),
+ currentChangesetId;
page.pushstate = page.popstate = function (path, id) {
OSM.loadSidebarContent(path, function () {
// Add each row
route.steps.forEach(function (step) {
- var ll = step[0],
- direction = step[1],
- instruction = step[2],
- dist = step[3],
- lineseg = step[4];
+ var ll = step[0],
+ direction = step[1],
+ instruction = step[2],
+ dist = step[3],
+ lineseg = step[4];
if (dist < 5) {
dist = "";
$("#maxlat").val(bounds.getNorth().toFixed(precision));
$("#export_overpass").attr("href",
- "https://overpass-api.de/api/map?bbox=" +
- $("#minlon").val() + "," + $("#minlat").val() + "," +
- $("#maxlon").val() + "," + $("#maxlat").val());
+ "https://overpass-api.de/api/map?bbox=" +
+ $("#minlon").val() + "," + $("#minlat").val() + "," +
+ $("#maxlon").val() + "," + $("#maxlat").val());
}
function validateControls() {
});
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);
}
for (var i = 0; i < changesets.length; ++i) {
var changeset = changesets[i],
- rect = L.rectangle(changeset.bounds,
- { weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 });
+ rect = L.rectangle(changeset.bounds,
+ { weight: 2, color: "#FF9500", opacity: 1, fillColor: "#FFFFAF", fillOpacity: 0 });
rect.id = changeset.id;
rect.addTo(group);
}
OSM.NewNote = function (map) {
var noteLayer = map.noteLayer,
- content = $("#sidebar_content"),
- page = {},
- addNoteButton = $(".control-note .control-button"),
- newNote,
- halo;
+ content = $("#sidebar_content"),
+ page = {},
+ addNoteButton = $(".control-note .control-button"),
+ newNote,
+ halo;
var noteIcons = {
"new": L.icon({
OSM.Note = function (map) {
var content = $("#sidebar_content"),
- page = {},
- halo, currentNote;
+ page = {},
+ halo, currentNote;
var noteIcons = {
"new": L.icon({
OSM.loadSidebarContent(path, function () {
initialize(function () {
var data = $(".details").data(),
- latLng = L.latLng(data.coordinates.split(","));
+ latLng = L.latLng(data.coordinates.split(","));
if (!map.getBounds().contains(latLng)) moveToNote();
});
});
content.find("textarea").val("").trigger("input");
var data = $(".details").data(),
- latLng = L.latLng(data.coordinates.split(","));
+ latLng = L.latLng(data.coordinates.split(","));
if (!map.hasLayer(halo)) {
halo = L.circleMarker(latLng, {
function moveToNote() {
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]+$/)) {
OSM.router.withoutMoveListener(function () {
OSM.Query = function (map) {
var url = OSM.OVERPASS_URL,
- 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"],
- marker;
+ 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"],
+ marker;
var featureStyle = {
color: "#FF6200",
if (prefixes[key]) {
var first = value.substr(0, 1).toUpperCase(),
- rest = value.substr(1).replace(/_/g, " ");
+ rest = value.substr(1).replace(/_/g, " ");
return first + rest;
}
function featureName(feature) {
var tags = feature.tags,
- locales = I18n.locales.get();
+ locales = I18n.locales.get();
for (var i = 0; i < locales.length; i++) {
if (tags["name:" + locales[i]]) {
function compareSize(feature1, feature2) {
var width1 = feature1.bounds.maxlon - feature1.bounds.minlon,
- height1 = feature1.bounds.maxlat - feature1.bounds.minlat,
- area1 = width1 * height1,
- width2 = feature2.bounds.maxlat - feature2.bounds.minlat,
- height2 = feature2.bounds.maxlat - feature2.bounds.minlat,
- area2 = width2 * height2;
+ height1 = feature1.bounds.maxlat - feature1.bounds.minlat,
+ area1 = width1 * height1,
+ width2 = feature2.bounds.maxlat - feature2.bounds.minlat,
+ height2 = feature2.bounds.maxlat - feature2.bounds.minlat,
+ area2 = width2 * height2;
return area1 - area2;
}
*/
function queryOverpass(lat, lng) {
var latlng = L.latLng(lat, lng).wrap(),
- bounds = map.getBounds().wrap(),
- bbox = bounds.getSouth() + "," + bounds.getWest() + "," + bounds.getNorth() + "," + bounds.getEast(),
- radius = 10 * Math.pow(1.5, 19 - map.getZoom()),
- around = "around:" + radius + "," + lat + "," + lng,
- nodes = "node(" + around + ")",
- ways = "way(" + around + ")",
- relations = "relation(" + around + ")",
- nearby = "(" + nodes + ";" + ways + ";);out tags geom(" + bbox + ");" + relations + ";out geom(" + bbox + ");",
- isin = "is_in(" + lat + "," + lng + ")->.a;way(pivot.a);out tags bb;out ids geom(" + bbox + ");relation(pivot.a);out tags bb;";
+ bounds = map.getBounds().wrap(),
+ bbox = bounds.getSouth() + "," + bounds.getWest() + "," + bounds.getNorth() + "," + bounds.getEast(),
+ radius = 10 * Math.pow(1.5, 19 - map.getZoom()),
+ around = "around:" + radius + "," + lat + "," + lng,
+ nodes = "node(" + around + ")",
+ ways = "way(" + around + ")",
+ relations = "relation(" + around + ")",
+ nearby = "(" + nodes + ";" + ways + ";);out tags geom(" + bbox + ");" + relations + ";out geom(" + bbox + ");",
+ isin = "is_in(" + lat + "," + lng + ")->.a;way(pivot.a);out tags bb;out ids geom(" + bbox + ");relation(pivot.a);out tags bb;";
$("#sidebar_content .query-intro")
.hide();
function clickHandler(e) {
var precision = OSM.zoomPrecision(map.getZoom()),
- latlng = e.latlng.wrap(),
- lat = latlng.lat.toFixed(precision),
- lng = latlng.lng.toFixed(precision);
+ latlng = e.latlng.wrap(),
+ lat = latlng.lat.toFixed(precision),
+ lng = latlng.lng.toFixed(precision);
OSM.router.route("/query?lat=" + lat + "&lon=" + lng);
}
page.load = function (path, noCentre) {
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)) {
OSM.router.withoutMoveListener(function () {
$(".describe_location").on("click", function (e) {
e.preventDefault();
var center = map.getCenter().wrap(),
- precision = OSM.zoomPrecision(map.getZoom());
+ precision = OSM.zoomPrecision(map.getZoom());
OSM.router.route("/search?whereami=1&query=" + encodeURIComponent(
center.lat.toFixed(precision) + "," + center.lng.toFixed(precision)
));
.toggleClass("disabled", disabled)
.attr("data-original-title",
I18n.t(disabled ?
- "javascripts.key.tooltip_disabled" :
- "javascripts.key.tooltip"));
+ "javascripts.key.tooltip_disabled" :
+ "javascripts.key.tooltip"));
}
function update() {
var layer = map.getMapBaseLayerId(),
- zoom = map.getZoom();
+ zoom = map.getZoom();
$(".mapkey-table-entry").each(function () {
var data = $(this).data();
.appendTo(item);
var input = $("<input>")
- .attr("type", "radio")
- .prop("checked", map.hasLayer(layer))
- .appendTo(label);
+ .attr("type", "radio")
+ .prop("checked", map.hasLayer(layer))
+ .appendTo(label);
label.append(layer.options.name);
}
var url = window.location.protocol + "//" + OSM.SERVER_URL + "/",
- query = querystring.stringify(params),
- hash = OSM.formatHash(this);
+ query = querystring.stringify(params),
+ hash = OSM.formatHash(this);
if (query) url += "?" + query;
if (hash) url += hash;
getShortUrl: function (marker) {
var zoom = this.getZoom(),
- latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
- str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
- window.location.protocol + "//osm.org/go/" :
- window.location.protocol + "//" + window.location.hostname + "/go/",
- char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~",
- x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)),
- y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)),
- // JavaScript only has to keep 32 bits of bitwise operators, so this has to be
- // done in two parts. each of the parts c1/c2 has 30 bits of the total in it
- // and drops the last 4 bits of the full 64 bit Morton code.
- c1 = interlace(x >>> 17, y >>> 17), c2 = interlace((x >>> 2) & 0x7fff, (y >>> 2) & 0x7fff),
- digit,
- i;
+ latLng = marker && this.hasLayer(marker) ? marker.getLatLng().wrap() : this.getCenter().wrap(),
+ str = window.location.hostname.match(/^www\.openstreetmap\.org/i) ?
+ window.location.protocol + "//osm.org/go/" :
+ window.location.protocol + "//" + window.location.hostname + "/go/",
+ char_array = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_~",
+ x = Math.round((latLng.lng + 180.0) * ((1 << 30) / 90.0)),
+ y = Math.round((latLng.lat + 90.0) * ((1 << 30) / 45.0)),
+ // JavaScript only has to keep 32 bits of bitwise operators, so this has to be
+ // done in two parts. each of the parts c1/c2 has 30 bits of the total in it
+ // and drops the last 4 bits of the full 64 bit Morton code.
+ c1 = interlace(x >>> 17, y >>> 17), c2 = interlace((x >>> 2) & 0x7fff, (y >>> 2) & 0x7fff),
+ digit,
+ i;
for (i = 0; i < Math.ceil((zoom + 8) / 3.0) && i < 5; ++i) {
digit = (c1 >> (24 - (6 * i))) & 0x3f;
function update() {
var wasDisabled = link.hasClass("disabled"),
- isDisabled = map.getZoom() < 14;
+ isDisabled = map.getZoom() < 14;
link
.toggleClass("disabled", isDisabled)
.attr("data-original-title", I18n.t(isDisabled ?
L.OSM.share = function (options) {
var control = L.control(options),
- marker = L.marker([0, 0], { draggable: true }),
- locationFilter = new L.LocationFilter({
- enableButton: false,
- adjustButton: false
- });
+ marker = L.marker([0, 0], { draggable: true }),
+ locationFilter = new L.LocationFilter({
+ enableButton: false,
+ adjustButton: false
+ });
control.onAdd = function (map) {
var $container = $("<div>")
}
var scale = $("#mapnik_scale").val(),
- size = L.bounds(L.CRS.EPSG3857.project(bounds.getSouthWest()),
- L.CRS.EPSG3857.project(bounds.getNorthEast())).getSize(),
- maxScale = Math.floor(Math.sqrt(size.x * size.y / 0.3136));
+ size = L.bounds(L.CRS.EPSG3857.project(bounds.getSouthWest()),
+ L.CRS.EPSG3857.project(bounds.getNorthEast())).getSize(),
+ maxScale = Math.floor(Math.sqrt(size.x * size.y / 0.3136));
$("#mapnik_minlon").val(bounds.getWest());
$("#mapnik_minlat").val(bounds.getSouth());
function getScale() {
var bounds = map.getBounds(),
- centerLat = bounds.getCenter().lat,
- halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180),
- meters = halfWorldMeters * (bounds.getEast() - bounds.getWest()) / 180,
- pixelsPerMeter = map.getSize().x / meters,
- metersPerPixel = 1 / (92 * 39.3701);
+ centerLat = bounds.getCenter().lat,
+ halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180),
+ meters = halfWorldMeters * (bounds.getEast() - bounds.getWest()) / 180,
+ pixelsPerMeter = map.getSize().x / meters,
+ metersPerPixel = 1 / (92 * 39.3701);
return Math.round(1 / (pixelsPerMeter * metersPerPixel));
}
L.OSM.sidebar = function (selector) {
var control = {},
- sidebar = $(selector),
- current = $(),
- currentButton = $(),
- map;
+ sidebar = $(selector),
+ current = $(),
+ currentButton = $(),
+ map;
control.addTo = function (_) {
map = _;
L.OSM.Zoom = L.Control.extend({
- options: {
- position: "topright"
- },
+ options: {
+ position: "topright"
+ },
- onAdd: function (map) {
- var zoomName = "zoom",
- container = L.DomUtil.create("div", zoomName);
+ onAdd: function (map) {
+ var zoomName = "zoom",
+ container = L.DomUtil.create("div", zoomName);
- this._map = map;
+ this._map = map;
- this._zoomInButton = this._createButton(
- "", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
- this._zoomOutButton = this._createButton(
- "", I18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this);
+ this._zoomInButton = this._createButton(
+ "", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
+ this._zoomOutButton = this._createButton(
+ "", 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) {
- map.off("zoomend zoomlevelschange", this._updateDisabled, this);
- },
+ onRemove: function (map) {
+ map.off("zoomend zoomlevelschange", this._updateDisabled, this);
+ },
- _zoomIn: function (e) {
- this._map.zoomIn(e.shiftKey ? 3 : 1);
- },
+ _zoomIn: function (e) {
+ this._map.zoomIn(e.shiftKey ? 3 : 1);
+ },
- _zoomOut: function (e) {
- this._map.zoomOut(e.shiftKey ? 3 : 1);
- },
+ _zoomOut: function (e) {
+ this._map.zoomOut(e.shiftKey ? 3 : 1);
+ },
- _createButton: function (html, title, className, container, fn, context) {
- var link = L.DomUtil.create("a", "control-button " + className, container);
- link.innerHTML = html;
- link.href = "#";
- link.title = title;
+ _createButton: function (html, title, className, container, fn, context) {
+ var link = L.DomUtil.create("a", "control-button " + className, container);
+ link.innerHTML = html;
+ link.href = "#";
+ 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
- .on(link, "click", stop)
- .on(link, "mousedown", stop)
- .on(link, "dblclick", stop)
- .on(link, "click", L.DomEvent.preventDefault)
- .on(link, "click", fn, context);
+ L.DomEvent
+ .on(link, "click", stop)
+ .on(link, "mousedown", stop)
+ .on(link, "dblclick", stop)
+ .on(link, "click", L.DomEvent.preventDefault)
+ .on(link, "click", fn, context);
- return link;
- },
+ return link;
+ },
- _updateDisabled: function () {
- var map = this._map,
- className = "disabled";
+ _updateDisabled: function () {
+ var map = this._map,
+ className = "disabled";
- L.DomUtil.removeClass(this._zoomInButton, className);
- L.DomUtil.removeClass(this._zoomOutButton, className);
+ L.DomUtil.removeClass(this._zoomInButton, className);
+ L.DomUtil.removeClass(this._zoomOutButton, className);
- if (map._zoom === map.getMinZoom()) {
- L.DomUtil.addClass(this._zoomOutButton, className);
- }
- if (map._zoom === map.getMaxZoom()) {
- L.DomUtil.addClass(this._zoomInButton, className);
- }
- }
+ if (map._zoom === map.getMinZoom()) {
+ L.DomUtil.addClass(this._zoomOutButton, className);
+ }
+ if (map._zoom === map.getMaxZoom()) {
+ L.DomUtil.addClass(this._zoomInButton, className);
+ }
+ }
});
L.OSM.zoom = function (options) {
- return new L.OSM.Zoom(options);
+ return new L.OSM.Zoom(options);
};
};
var currentPath = window.location.pathname.replace(/(.)\/$/, "$1") + window.location.search,
- currentRoute = routes.recognize(currentPath),
- currentHash = location.hash || OSM.formatHash(map);
+ currentRoute = routes.recognize(currentPath),
+ currentHash = location.hash || OSM.formatHash(map);
var router = {};
$(window).on("popstate", function (e) {
if (!e.originalEvent.state) return; // Is it a real popstate event or just a hash change?
var path = window.location.pathname + window.location.search,
- route = routes.recognize(path);
+ route = routes.recognize(path);
if (path === currentPath) return;
currentRoute.run("unload", null, route === currentRoute);
currentPath = path;
router.route = function (url) {
var path = url.replace(/#.*/, ""),
- route = routes.recognize(path);
+ route = routes.recognize(path);
if (!route) return false;
currentRoute.run("unload", null, route === currentRoute);
var state = OSM.parseHash(url);
"eol-last": "error",
"eqeqeq": ["error", "smart"],
"func-call-spacing": "error",
+ "indent": ["error", 2, {
+ "SwitchCase": 1,
+ "VariableDeclarator": "first",
+ "FunctionDeclaration": { "parameters": "first" },
+ "FunctionExpression": { "parameters": "first" },
+ "CallExpression": { "arguments": "first" }
+ }],
"key-spacing": "error",
"keyword-spacing": "error",
"no-alert": "warn",