Class: OembedProxy::GoogleMapsengine

Inherits:
Object
  • Object
show all
Defined in:
lib/oembed_proxy/google_mapsengine.rb

Overview

Google Maps Engine Fauxembed

Constant Summary collapse

MAPSENGINE_REGEXES =
[
  %r{\Ahttps://mapsengine\.google\.com/map/(?:edit|view)\?mid=(.+)},
  %r{\Ahttps://www\.google\.com/maps/d/edit\?mid=(.+)},
].freeze

Instance Method Summary collapse

Instance Method Details

#get_data(url, _other_params = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/oembed_proxy/google_mapsengine.rb', line 15

def get_data(url, _other_params = {})
  return nil unless handles_url? url

  {
    'type' => 'rich',
    'version' => '1.0',
    'provider_name' => 'Google Maps Engine',
    'provider_url' => 'https://mapsengine.google.com/',
    'html' => "<iframe class=\"google-map\" width=\"640\" height=\"480\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"https://mapsengine.google.com/map/embed?mid=#{url.match(get_matching_regex(url))[1]}\"></iframe>",
    'width' => 500,
    'height' => 500,
  }
end

#handles_url?(url) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/oembed_proxy/google_mapsengine.rb', line 11

def handles_url?(url)
  !get_matching_regex(url).nil?
end