# Google Maps onebox issues

**URL:** https://meta.discourse.org/t/google-maps-onebox-issues/27989
**Category:** Bug
**Created:** [April 27, 2015, 10:24am UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989 "2015-04-27T10:24:46Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)
#### Post date: [April 27, 2015, 10:24am UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/1 "2015-04-27T10:24:47Z")

</div>

`.be` link:

https://maps.google.com/maps?ll=51.2285173,4.4336702&z=17&output=embed&dg=ntvb&q=Den+Abattoir&cid=18157036796216755994

`.co.uk` link:

https://maps.google.com/maps?ll=51.2285173,4.4336702&z=17&output=embed&dg=ntvb&q=Den+Abattoir&cid=18157036796216755994

Both oneboxes show in preview, but not when cooked.

@boomzilla was able to uncover some extra info:  
`Job exception: undefined method 'split' for nil:NilClass`

Env:

```plaintext
current_db: default
current_hostname: what.thedailywtf.com
message: While trying to onebox a URL
url: https://www.google.com.a/maps/place/Rheinbiss+652/@50.718779,7.129456,17z/data=!3m1!4b1!4m2!3m1!1s0x47bee15c59b6b135:0x9d379982efb7740b

```

Backtrace (partial):

```plaintext
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:31:in `resolve_url!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:10:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `engine'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:13:in `to_s'

```

`Job exception: bad argument (expected URI object or URI string)`

```plaintext
current_db: default
current_hostname: what.thedailywtf.com
message: While trying to onebox a URL
url: http://www.google.co.uk/mapmaker

```

```plaintext
/usr/local/lib/ruby/2.0.0/uri/common.rb:998:in `URI'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:31:in `resolve_url!'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/engine/classic_google_maps_onebox.rb:10:in `initialize'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `new'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:67:in `engine'
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/onebox-1.5.16/lib/onebox/preview.rb:13:in `to_s'
/var/www/discourse/lib/oneboxer.rb:126:in `block in onebox_raw'

```

---

<div class="post-metadata">

### Author: ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)
#### Post date: [April 27, 2015, 10:25am UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/2 "2015-04-27T10:25:38Z")

</div>

…and as luck would have it, they both work here 😒

Anyway, somewhere where the issue _is_ visible:

> **[What the Daily WTF?](https://what.thedailywtf.com/login)**

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [April 27, 2015, 10:28am UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/3 "2015-04-27T10:28:46Z")

</div>

I believe we’re recently fixed the google maps onebox. Are you running the latest version at TDW?

---

<div class="post-metadata">

### Author: ![RaceProUK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/raceprouk/32/115844_2.png) [@RaceProUK](https://meta.discourse.org/u/RaceProUK)
#### Post date: [April 27, 2015, 10:40am UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/4 "2015-04-27T10:40:01Z")

</div>

I guess not; I’ll ask

Edit: Asked

> **[What the Daily WTF?](https://what.thedailywtf.com/login)**

---

<div class="post-metadata">

### Author: ![anon21958287](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@anon21958287](https://meta.discourse.org/u/anon21958287)
#### Post date: [April 27, 2015, 10:44am UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/5 "2015-04-27T10:44:25Z")

</div>

> [@zogstrip](#):
>
> Are you running the latest version at TDW?

Latest Beta:

![](https://global.discourse-cdn.com/meta/original/3X/7/5/752ebc3853a0826f8638a877839057082dd397b5.png)

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 27, 2015, 3:56pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/6 "2015-04-27T15:56:43Z")

</div>

Oh joy. **Another** type of Google maps URL…

![](https://global.discourse-cdn.com/meta/original/3X/2/3/2381d02367b932243b540d17b393587fac33557a.gif)

The problem is that these URLs do not resolve into “canonical” URLs, so the _current_ version of the oneboxer simply bails out. I have no idea why the one on meta accepts these URLs… is this perhaps actually an older version?

Anyway, I’ll take care of this.

---

<div class="post-metadata">

### Author: ![anon21958287](https://avatars.discourse-cdn.com/v4/letter/a/ee59a6/32.png) [@anon21958287](https://meta.discourse.org/u/anon21958287)
#### Post date: [April 27, 2015, 4:08pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/7 "2015-04-27T16:08:49Z")

</div>

> [@elberet](#):
>
> The problem is that these URLs do not resolve into “canonical” URLs, so the current version of the oneboxer simply bails out. I have no idea why the one on meta accepts these URLs… is this perhaps actually an older version?

Except that the stuff works in the preview but not the final post (in the older version we’re running, not the latest version here on meta, where it all seems to work).

There have been (and surely still are) a lot of things that work differently in preview and final. Which is insane from a user’s point of view.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 27, 2015, 5:12pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/8 "2015-04-27T17:12:49Z")

</div>

Actually, no, things shouldn’t be working differently in preview and final. Both are processed by the same JavaScript code, and both invoke the same onebox engines. Oneboxes may be rendered differently in preview to avoid rapid reloading of iframes (after all, each time the preview is re-rendered, the entire cooked HTML is ripped out of the DOM and replaced), but as far as the `GoogleMapsOnebox` engine is concerned, both cases invoke the exact same code path through the initializer and resolve method.

As for why it works in preview but not in the final result? Heck if I knew. Right now, when you invoke the current version of `GoogleMapsOnebox` with either URL you’ve posted above, the engine’s initializer raises an `ArgumentError` because it doesn’t recognize the URL. 😕

---

<div class="post-metadata">

### Author: ![georgiano](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@georgiano](https://meta.discourse.org/u/georgiano)
#### Post date: [April 27, 2015, 6:30pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/9 "2015-04-27T18:30:57Z")

</div>

…and the regexp describing google maps url would be joy to read 🙂

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 27, 2015, 7:14pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/10 "2015-04-27T19:14:56Z")

</div>

I have a fix here:

[https://github.com/discourse/onebox/pull/293](https://github.com/discourse/onebox/pull/293)

This is a “best effort” solution.

1. Previews _must be static images_ or else each update of the composer preview pane would cause a reload of the embedded iframe. Google would probably consider this abuse, and browser performance would plummet straight to hell.

2. I can only display static maps using data found in any of the available URLs that directly maps to data the static map API will accept. This is _not_ the case for the `cid` field that contains the ID of the custom map, let alone the protobuf-encoded `data` field in the source URL. Thus, markers placed on custom maps will not appear on any previews.

3. For a reason I have not (yet) figured out, Google’s webserver does sometimes, but not always, redirect @RaceProUK’s source URLs to the “canonical” Google maps URL. This seems to be totally random and may or may not be a transient problem. The engine now tries up to 10 times to get the canonical URL; if this fails, it constructs a fallback more or less blindly, based on assumptions and circumstancial evidence regarding the encoding of the `data` parameter.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [April 27, 2015, 7:46pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/11 "2015-04-27T19:46:49Z")

</div>

By the way: the second URL fails because you _do_ have an outdated onebox version. `classic_google_maps_onebox.rb` no longer exists in the current version of the gem.

@zogstrip, should I bump onebox’s version in my PRs?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 29, 2015, 5:04am UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/12 "2015-04-29T05:04:38Z")

</div>

sure bump the version we can do an update.

---

<div class="post-metadata">

### Author: ![BCHK](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bchk/32/3268_2.png) [@BCHK](https://meta.discourse.org/u/BCHK)
#### Post date: [May 5, 2015, 4:36pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/13 "2015-05-05T16:36:43Z")

</div>

Yes - my users are complaining about this issue too. I try to post a map, it shows up in preview, and for just a second or two in the final post, then it disappears.

https://maps.google.com/maps?ll=-17.4624892,179.2583049&z=7&output=embed&dg=ntvb&q=Fiji&cid=146347827704248055956320518723215514515

---

<div class="post-metadata">

### Author: ![georgiano](https://avatars.discourse-cdn.com/v4/letter/g/58956e/32.png) [@georgiano](https://meta.discourse.org/u/georgiano)
#### Post date: [May 6, 2015, 1:07pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/14 "2015-05-06T13:07:36Z")

</div>

Yep, It’s already a month since last version update 😄

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [August 22, 2015, 3:29pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/15 "2015-08-22T15:29:03Z")

</div>

This issue seems to be fixed now? I can’t repro it.

Also there was an issue with Google Street View maps, just fixed that via:

[https://github.com/discourse/onebox/commit/7369fc7528252fb87536ad9065455c5665ea5b5e](https://github.com/discourse/onebox/commit/7369fc7528252fb87536ad9065455c5665ea5b5e)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 1, 2016, 3:33pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/16 "2016-01-01T15:33:59Z")

</div>

This issue is fixed now.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [January 1, 2016, 3:34pm UTC](https://meta.discourse.org/t/google-maps-onebox-issues/27989/17 "2016-01-01T15:34:03Z")

</div>


