Add a Geo URI link to the share panel

Fixes #799
This commit is contained in:
Eric Theise 2015-06-25 17:55:41 +01:00 committed by Tom Hughes
parent 4676179879
commit 6403cb9b08
4 changed files with 41 additions and 1 deletions

View file

@ -170,6 +170,24 @@ L.OSM.Map = L.Map.extend({
return str;
},
getGeoUri: function(marker) {
var precision = OSM.zoomPrecision(this.getZoom()),
latLng,
params = {};
if (marker && this.hasLayer(marker)) {
latLng = marker.getLatLng().wrap();
} else {
latLng = this.getCenter();
}
params.lat = latLng.lat.toFixed(precision);
params.lon = latLng.lng.toFixed(precision);
params.zoom = this.getZoom();
return 'geo:' + params.lat + ',' + params.lon + '?z=' + params.zoom;
},
addObject: function(object, callback) {
var objectStyle = {
color: "#FF6200",

View file

@ -120,6 +120,21 @@ L.OSM.share = function (options) {
.text(I18n.t('javascripts.share.paste_html'))
.appendTo($linkSection));
// Geo URI
var $geoUriSection = $('<div>')
.attr('class', 'section share-geo-uri')
.appendTo($ui);
$('<h4>')
.text(I18n.t('javascripts.share.geo_uri'))
.appendTo($geoUriSection);
$('<div>')
.appendTo($geoUriSection)
.append($('<a>')
.attr('id', 'geo_uri'));
// Image
var $imageSection = $('<div>')
@ -320,6 +335,12 @@ L.OSM.share = function (options) {
'<small><a href="' + escapeHTML(map.getUrl(marker)) + '">' +
escapeHTML(I18n.t('javascripts.share.view_larger_map')) + '</a></small>');
// Geo URI
$('#geo_uri')
.attr('href', map.getGeoUri(marker))
.html(map.getGeoUri(marker));
// Image
if (locationFilter.isEnabled()) {

View file

@ -721,6 +721,7 @@ nav.secondary {
text-decoration: none;
background-color: $lightblue;
padding: 5px 10px;
border-right: 1px solid #fff;
}
a:first-child {
@ -729,7 +730,6 @@ nav.secondary {
}
a:last-child {
border-left: 1px solid #fff;
border-radius: 0 4px 4px 0;
}

View file

@ -2163,6 +2163,7 @@ en:
link: "Link or HTML"
long_link: "Link"
short_link: "Short Link"
geo_uri: "Geo URI"
embed: "HTML"
custom_dimensions: "Set custom dimensions"
format: "Format:"