简体   繁体   中英

Google static maps with encoded paths don't show when posting HTML page to OneNote REST API

I am POSTing an HTML page to the OneNote REST API, to:

https://www.onenote.com/api/v1.0/pages

I am doing this from Google App engine (Java), and it all works fine, except that I am having problems with the static Google maps that are linked within the HTML.

Specifically a static map WITHOUT an encoded path is working and showing up fine, eg:

http://maps.googleapis.com/maps/api/staticmap?key=<KEY>&sensor=false&
center=<LAT,LON>&scale=1&zoom=17&markers=<LAT,LON>&size=150x150

However, when I post including an encoded polyline, the images doesn't show up on the OneNote page that is created (it looks a broken link on the page), eg:

http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=150x150&
scale=1&path=enc:<PATH>&markers=<BLAH>&key=<KEY>

My first thought was that it wouldn't work because the google maps key can only be used from my own domain (although that wouldn't explain why the maps without encoded polylines worked already), so I added

https://www.onenote.com/* 

to list of referrers. (I don't know that's the right referrer - just a guess based on the API URL). That didn't solve the problem.

Then I thought maybe it's because MS doesn't allow google maps on OneNote (or Google doesn't allow Google maps on OneNote). So I tried serving the google maps via my own website. That didn't work either. But what I could see from my server logs is that OneNote didn't even called the URL on my website of the maps with encoded polylines - which is weird!

The final idea I had is that maybe it's because the URL with encoded polyline is too long for the OneNote API to handle. So one thing I could try is to create short URLs to put in the HTML. Before I try that final step, thought I would ask for advice in case I am still headed the wrong way...

Thanks.

Edit: Here's an example of a URL that didn't work (excluding the key only):

http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=150x150&scale=1&
path=enc:obblHzpwnVY?QEmBqA@qEzDT|JeAtD{Qn@yQhD_CMeIZ}BeCO@A@A?H
&markers=label:S|49.331765,-123.169574|&markers=label:F|49.328255,-123.158863&
key=<KEY>

Note that the key is approx 40 characters long

This appears to have been a length of URL problem. I tried serving the maps from my own website with a very short URL...

http://MY_DOMAIN/mapwrapper/SHORT_KEY

....and they worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM