X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/781e80181e629271722b7781809729c0949c262a..35fbcf28154b6f15f697018016fbabc952e018a5:/app/assets/javascripts/embed.js.erb diff --git a/app/assets/javascripts/embed.js.erb b/app/assets/javascripts/embed.js.erb index eec4b080e..ca5594459 100644 --- a/app/assets/javascripts/embed.js.erb +++ b/app/assets/javascripts/embed.js.erb @@ -13,6 +13,7 @@ window.onload = function () { var map = L.map("map"); map.attributionControl.setPrefix(''); + map.removeControl(map.attributionControl); if (!args.layer || args.layer === "mapnik" || args.layer === "osmarender") { new L.OSM.Mapnik().addTo(map); @@ -43,4 +44,31 @@ window.onload = function () { } else { map.fitWorld(); } + + map.addControl(new L.Control.OSMReportAProblem()); }; + +L.Control.OSMReportAProblem = L.Control.Attribution.extend({ + options: { + position: 'bottomright', + prefix: 'Report a problem' + }, + + onAdd: function (map) { + var container = L.Control.Attribution.prototype.onAdd.call(this, map); + + map.on('moveend', this._update, this); + + return container; + }, + + _update: function () { + L.Control.Attribution.prototype._update.call(this); + + this._container.innerHTML = + this._container.innerHTML + .replace('{x}', this._map.getCenter().lat) + .replace('{y}', this._map.getCenter().lng) + .replace('{z}', this._map.getZoom()); + } +});