简体   繁体   English

带有数字符号/井号/井号标签的查询的 Google Maps Embed 调用失败

[英]Google Maps Embed call failing for queries with number signs / pound signs / hash tags

My application throws the error:我的应用程序抛出错误:

Google Maps Platform rejected your request. Google Maps Platform 拒绝了您的请求。 You must use an API key to authenticate each request to Google Maps Platform APIs.您必须使用 API 密钥来验证对 Google Maps Platform API 的每个请求。 For additional information, please refer to http://g.co/dev/maps-no-account有关其他信息,请参阅http://g.co/dev/maps-no-account

I've tried reproducing the bug with a variety of query strings.我尝试使用各种查询字符串重现该错误。 It appears that the only time that the query fails is when there's a # for a suite number or apartment number.似乎查询失败的唯一时间是当套房号或公寓号有 # 时。

This works: https://www.google.com/maps/embed/v1/place?q=17426%20Northwest%20Fwy,%20Jersey%20Village,%20TX%2077040,%20USA&key=这有效: https : //www.google.com/maps/embed/v1/place?q=17426%20Northwest%20Fwy,%20Jersey%20Village,%20TX%2077040,%20USA&key=

This does not work: https://www.google.com/maps/embed/v1/place?q=951%20Interstate%20Hwy%2030%20#105,%20Rockwall,%20TX%2075087,%20USA&key=这不起作用: https : //www.google.com/maps/embed/v1/place?q=951%20Interstate%20Hwy%2030%20#105,%20Rockwall,%20TX%2075087,%20USA&key=

A potential solution is that I omit the # tags and just use the Place IDs when I get the initial address.一个潜在的解决方案是我省略 # 标签,并在获得初始地址时仅使用地点 ID。

That requires a huge code refactor, so I would really love not to.这需要大量的代码重构,所以我真的很不想这样做。

The "#" reserved character is usually used as an anchor for linking subsections and is one of those special characters that should be encoded in URLs. “#”保留字符通常用作链接小节的锚点,并且是应该在 URL 中编码的那些特殊字符之一。

Try this: https://www.google.com/maps/embed/v1/place?q=951%20Interstate%20Hwy%2030%20%23105,%20Rockwall,%20TX%2075087,%20USA&key=试试这个: https : //www.google.com/maps/embed/v1/place?q=951%20Interstate%20Hwy%2030%20%23105,%20Rockwall,%20TX%2075087,%20USA&key=

Refer to Google's documentation on URL encoding for more details.有关更多详细信息,请参阅 Google 关于URL 编码的文档。

Hope this helps!希望这可以帮助!

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

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