]> git.openstreetmap.org Git - rails.git/commitdiff
Add a Geo URI link to the share panel
authorEric Theise <erictheise@gmail.com>
Thu, 25 Jun 2015 16:55:41 +0000 (17:55 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 25 Jun 2015 16:56:03 +0000 (17:56 +0100)
Fixes #799

app/assets/javascripts/leaflet.map.js
app/assets/javascripts/leaflet.share.js
app/assets/stylesheets/common.scss
config/locales/en.yml

index f433cd3713181fdeaa6cd6f9bee5727b860b8d34..58360bbec57513bbd738db621ab79bca00008cd2 100644 (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",
index 44d02c0973f30f92766babce8a5c02090ba05cb2..b991210dfad5a063fcc48d76181c0deb5e72a2c6 100644 (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()) {
index e8696d665ef32b9c71c54d8f42b9e224d3a1fa15..21cecaf4aa67da1e94b89b433f4dcfed1ffcbcbb 100644 (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;
     }
 
index 0a6f108e7ee4def2d88f75f84a68418304bb976c..5b439fdae22cf442de478bbc608a5fdceecce8dc 100644 (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:"