LAYERS_WITH_MAP_KEY: <%= YAML.load_file(Rails.root.join("config/key.yml")).keys.to_json %>,
MARKER_GREEN: <%= image_path("marker-green.png").to_json %>,
LAYERS_WITH_MAP_KEY: <%= YAML.load_file(Rails.root.join("config/key.yml")).keys.to_json %>,
MARKER_GREEN: <%= image_path("marker-green.png").to_json %>,
- var params = OSM.params(search), mapParams = {}, loc, match;
+ var params = OSM.params(search), mapParams = {}, match;
// Decide on a map starting position. Various ways of doing this.
if (hash.center) {
mapParams.lon = hash.center.lng;
mapParams.lat = hash.center.lat;
mapParams.zoom = hash.zoom;
} else if (params.bbox) {
// Decide on a map starting position. Various ways of doing this.
if (hash.center) {
mapParams.lon = hash.center.lng;
mapParams.lat = hash.center.lat;
mapParams.zoom = hash.zoom;
} else if (params.bbox) {
mapParams.bounds = L.latLngBounds(
[parseFloat(bbox[1]), parseFloat(bbox[0])],
[parseFloat(bbox[3]), parseFloat(bbox[2])]);
mapParams.bounds = L.latLngBounds(
[parseFloat(bbox[1]), parseFloat(bbox[0])],
[parseFloat(bbox[3]), parseFloat(bbox[2])]);
} else if (params.mlon && params.mlat) {
mapParams.lon = parseFloat(params.mlon);
mapParams.lat = parseFloat(params.mlat);
} else if (params.mlon && params.mlat) {
mapParams.lon = parseFloat(params.mlon);
mapParams.lat = parseFloat(params.mlat);
} else if (OSM.home) {
mapParams.lon = OSM.home.lon;
mapParams.lat = OSM.home.lat;
mapParams.zoom = 10;
} else if (OSM.location) {
mapParams.bounds = L.latLngBounds(
} else if (OSM.home) {
mapParams.lon = OSM.home.lon;
mapParams.lat = OSM.home.lat;
mapParams.zoom = 10;
} else if (OSM.location) {
mapParams.bounds = L.latLngBounds(
- var map = (hash.map || '').split('/'),
- zoom = parseInt(map[0], 10),
- lat = parseFloat(map[1]),
- lon = parseFloat(map[2]);
+ var map = (hash.map || "").split("/"),
+ zoom = parseInt(map[0], 10),
+ lat = parseFloat(map[1]),
+ lon = parseFloat(map[2]);
if (!isNaN(zoom) && !isNaN(lat) && !isNaN(lon)) {
args.center = new L.LatLng(lat, lon);
if (!isNaN(zoom) && !isNaN(lat) && !isNaN(lon)) {
args.center = new L.LatLng(lat, lon);
var center, zoom, layers;
if (args instanceof L.Map) {
var center, zoom, layers;
if (args instanceof L.Map) {
- hash = '#map=' + zoom +
- '/' + center.lat.toFixed(precision) +
- '/' + center.lng.toFixed(precision);
+ hash = "#map=" + zoom +
+ "/" + center.lat.toFixed(precision) +
+ "/" + center.lng.toFixed(precision);
- zoomPrecision: function(zoom) {
- return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+ zoomPrecision: function (zoom) {
+ var pixels = Math.pow(2, 8 + zoom);
+ var degrees = 180;
+ return Math.ceil(Math.log10(pixels / degrees));
- zoom = map.getZoom(),
- precision = OSM.zoomPrecision(zoom);
- return [center.lng.toFixed(precision), center.lat.toFixed(precision), zoom, map.getLayersCode()].join('|');
+ zoom = map.getZoom(),
+ precision = OSM.zoomPrecision(zoom);
+ return [center.lng.toFixed(precision), center.lat.toFixed(precision), zoom, map.getLayersCode()].join("|");
- lng1 = latlng1.lng * Math.PI / 180,
- lat2 = latlng2.lat * Math.PI / 180,
- lng2 = latlng2.lng * Math.PI / 180,
- latdiff = lat2 - lat1,
- lngdiff = lng2 - lng1;
+ lng1 = latlng1.lng * Math.PI / 180,
+ lat2 = latlng2.lat * Math.PI / 180,
+ lng2 = latlng2.lng * Math.PI / 180,
+ latdiff = lat2 - lat1,
+ lngdiff = lng2 - lng1;