$(document).ready(function () {
function remoteEditHandler(bbox, select) {
- var left = bbox.getWestLng() - 0.0001;
- var top = bbox.getNorthLat() + 0.0001;
- var right = bbox.getEastLng() + 0.0001;
- var bottom = bbox.getSouthLat() - 0.0001;
+ var left = bbox.getWest() - 0.0001;
+ var top = bbox.getNorth() + 0.0001;
+ var right = bbox.getEast() + 0.0001;
+ var bottom = bbox.getSouth() - 0.0001;
var loaded = false;
$("#linkloader").load(function () { loaded = true; });
});
updatelinks(params.lon, params.lat, 16, null,
- bbox.getWestLng(), bbox.getSouthLat(),
- bbox.getEastLng(), bbox.getNorthLat(),
+ bbox.getWest(), bbox.getSouth(),
+ bbox.getEast(), bbox.getNorth(),
object);
} else {
$("#object_larger_map").hide();
updatelinks(centre.lng,
centre.lat,
16, null,
- extent.getWestLng(),
- extent.getSouthLat(),
- extent.getEastLng(),
- extent.getNorthLat(),
+ extent.getWest(),
+ extent.getSouth(),
+ extent.getEast(),
+ extent.getNorth(),
object);
} else {
$("#small_map").hide();
center.lat,
zoom,
layers,
- extents.getWestLng(),
- extents.getSouthLat(),
- extents.getEastLng(),
- extents.getNorthLat(),
+ extents.getWest(),
+ extents.getSouth(),
+ extents.getEast(),
+ extents.getNorth(),
params.object);
var expiry = new Date();
var loaded = false;
$("#linkloader").load(function () { loaded = true; });
- $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.getWestLng()
- + "&bottom=" + extent.getSouthLat()
- + "&right=" + extent.getEastLng()
- + "&top=" + extent.getNorthLat());
+ $("#linkloader").attr("src", "http://127.0.0.1:8111/load_and_zoom?left=" + extent.getWest()
+ + "&bottom=" + extent.getSouth()
+ + "&right=" + extent.getEast()
+ + "&top=" + extent.getNorth());
setTimeout(function () {
if (!loaded) alert(I18n.t('site.index.remote_failed'));
$("#sidebar_title").html(I18n.t('site.sidebar.search_results'));
$("#sidebar_content").load($(this).attr("action"), {
query: $("#query").val(),
- minlon: bounds.getWestLng(),
- minlat: bounds.getSouthLat(),
- maxlon: bounds.getEastLng(),
- maxlat: bounds.getNorthLat()
+ minlon: bounds.getWest(),
+ minlat: bounds.getSouth(),
+ maxlon: bounds.getEast(),
+ maxlat: bounds.getNorth()
}, openSidebar);
return false;
setStatus(I18n.t('browse.start_rjs.loading'));
- var url = "/api/" + OSM.API_VERSION + "/map?bbox=" + bounds.toBBOX();
+ var url = "/api/" + OSM.API_VERSION + "/map?bbox=" + bounds.toBBoxString();
/*
* Modern browsers are quite happy showing far more than 100 features in
var bounds = map.getBounds(),
centerLat = bounds.getCenter().lat,
halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180),
- meters = halfWorldMeters * (bounds.getNorthEast().lng - bounds.getSouthWest().lng) / 180,
+ meters = halfWorldMeters * (bounds.getEast() - bounds.getWest()) / 180,
pixelsPerMeter = map.getSize().x / meters,
metersPerPixel = 1 / (92 * 39.3701);
return Math.round(1 / (pixelsPerMeter * metersPerPixel));
function setBounds(bounds) {
var toPrecision = zoomPrecision(map.getZoom());
- $("#minlon").val(toPrecision(bounds.getWestLng()));
- $("#minlat").val(toPrecision(bounds.getSouthLat()));
- $("#maxlon").val(toPrecision(bounds.getEastLng()));
- $("#maxlat").val(toPrecision(bounds.getNorthLat()));
+ $("#minlon").val(toPrecision(bounds.getWest()));
+ $("#minlat").val(toPrecision(bounds.getSouth()));
+ $("#maxlon").val(toPrecision(bounds.getEast()));
+ $("#maxlat").val(toPrecision(bounds.getNorth()));
mapnikSizeChanged();
htmlUrlChanged();
var bounds = getBounds();
var layerName = getMapBaseLayer().keyid;
- var url = "http://" + OSM.SERVER_URL + "/export/embed.html?bbox=" + bounds.toBBOX() + "&layer=" + layerName;
+ var url = "http://" + OSM.SERVER_URL + "/export/embed.html?bbox=" + bounds.toBBoxString() + "&layer=" + layerName;
var markerUrl = "";
if ($("#marker_lat").val() && $("#marker_lon").val()) {
}
function maxMapnikScale() {
- var bounds = getMercatorBounds();
+ var size = getMercatorBounds().getSize();
- return Math.floor(Math.sqrt(bounds.getWidth() * bounds.getHeight() / 0.3136));
+ return Math.floor(Math.sqrt(size.x * size.y / 0.3136));
}
function mapnikImageSize(scale) {
- var bounds = getMercatorBounds();
+ var size = getMercatorBounds().getSize();
- return {w: Math.round(bounds.getWidth() / scale / 0.00028),
- h: Math.round(bounds.getHeight() / scale / 0.00028)};
+ return {w: Math.round(size.x / scale / 0.00028),
+ h: Math.round(size.y / scale / 0.00028)};
}
function roundScale(scale) {
var size = bounds.getSize();
if (size <= OSM.MAX_NOTE_REQUEST_AREA) {
- var url = "/api/" + OSM.API_VERSION + "/notes.json?bbox=" + bounds.toBBOX();
+ var url = "/api/" + OSM.API_VERSION + "/notes.json?bbox=" + bounds.toBBoxString();
if (noteLoader) noteLoader.abort();
// Leaflet extensions
L.extend(L.LatLngBounds.prototype, {
- getSouthLat: function () {
- return this._southWest.lat;
- },
-
- getWestLng: function () {
- return this._southWest.lng;
- },
-
- getNorthLat: function () {
- return this._northEast.lat;
- },
-
- getEastLng: function () {
- return this._northEast.lng;
- },
-
- toBBOX: function () {
- var decimal = 6;
- var mult = Math.pow(10, decimal);
- var xmin = Math.round(this.getWestLng() * mult) / mult;
- var ymin = Math.round(this.getSouthLat() * mult) / mult;
- var xmax = Math.round(this.getEastLng() * mult) / mult;
- var ymax = Math.round(this.getNorthLat() * mult) / mult;
- return xmin + "," + ymin + "," + xmax + "," + ymax;
- },
-
getSize: function () {
return (this._northEast.lat - this._southWest.lat) *
(this._northEast.lng - this._southWest.lng);
}
});
-L.extend(L.Bounds.prototype, {
- getWidth: function () {
- return this.max.x - this.min.x;
- },
-
- getHeight: function () {
- return this.max.y - this.min.y;
- }
-});
-
L.Icon.Default.imagePath = <%= "#{asset_prefix}/images".to_json %>;
var map;