简体   繁体   English

将HTML页面发布到OneNote REST API时,不显示带有编码路径的Google静态地图

[英]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: 我将HTML页面发布到OneNote REST API,以:

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. 我正在通过Google App引擎(Java)进行此操作,并且一切正常,除了我在HTML内链接的静态Google地图存在问题之外。

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: 但是,当我发布包含编码折线的信息时,图像不会显示在创建的OneNote页面上(在页面上看起来是断开的链接),例如:

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 我的第一个想法是,由于google maps密钥只能在我自己的域中使用,因此它不起作用(尽管那不能解释为什么没有编码折线的地图已经可以工作),所以我添加了

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). (我不知道这是正确的引荐来源-只是基于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). 然后我想也许是因为MS不允许在OneNote上使用Google地图(或Google不允许在OneNote上使用Google地图)。 So I tried serving the google maps via my own website. 因此,我尝试通过自己的网站提供Google地图。 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! 但是我从服务器日志中可以看到的是,OneNote甚至没有在我的带有编码折线的地图网站上调用URL,这很奇怪!

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. 我最后的想法是,可能是因为带有编码折线的URL对于OneNote API来说太长了。 So one thing I could try is to create short URLs to put in the HTML. 因此,我可以尝试做的一件事就是创建短网址以放入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): 编辑:这是一个无效的URL的示例(仅排除密钥):

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 请注意,密钥约为40个字符长

This appears to have been a length of URL problem. 这似乎是URL长度的问题。 I tried serving the maps from my own website with a very short URL... 我尝试通过自己的网站以非常短的网址提供地图...

http://MY_DOMAIN/mapwrapper/SHORT_KEY

....and they worked fine. ....他们工作得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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