aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Rataj <lidel@lidel.org>2014-11-12 22:37:45 +0100
committerMarcin Rataj <lidel@lidel.org>2014-11-12 22:37:45 +0100
commit4be377701b5ac2a10a273f3d5eb7a4f41b7de9ec (patch)
treec82525d08295e48b4625e8c3dbeddbacc1d05a12
parent98ce24f33b830a82cd5d380687d8af6d2db885e4 (diff)
downloaddiscourse-umap-4be377701b5ac2a10a273f3d5eb7a4f41b7de9ec.tar.gz
Layer support and bugfixes
-rw-r--r--plugin.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/plugin.rb b/plugin.rb
index cbe2019..2185a0b 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -18,16 +18,20 @@ class Onebox::Engine::OpenStreetMapOnebox
matches_regexp(/^https?:\/\/(?:www\.)openstreetmap\.org/)
def to_html
- if match = @url.match(/#map=([\d\.]+)\/([\d\.]+)\/([\d\.]+)/)
+ if match = @url.match(/#map=([\d\.]+)\/([-\d\.]+)\/([-\d\.]+)/)
zoom, lat, lon = match.captures
iframe_url = "//www.openstreetmap.org/export/embed.html?bbox=#{get_bbox(lat.to_f, lon.to_f, zoom.to_i)}"
- if marker = @url.match(/mlat=([\d\.]+).+mlon=([\d\.]+)/)
+ if marker = @url.match(/mlat=([-\d\.]+).+mlon=([-\d\.]+)/)
mlat, mlon = marker.captures
iframe_url = "#{iframe_url}&amp;marker=#{mlat}%2C#{mlon}"
end
- "<iframe src='#{iframe_url}' style='border: 0' width='#{@@width.to_i}' height='#{@@height.to_i}' frameborder='0' scrolling='no'></iframe>"
+ if layers = @url.match(/layers=(\w+)/)
+ iframe_url = "#{iframe_url}&amp;layers=#{layers.captures[0]}"
+ end
+
+ "<iframe src='#{iframe_url}' style='border: 0' width='#{@@width}' height='#{@@height}' frameborder='0' scrolling='no'></iframe>"
else
#"NOPE" #@url
@url