带有中心纬度的 Google Maps Embed API 显示图钉

Whi*_*her 2 google-maps google-maps-api-3

我正在使用这样的 Google Maps Embed API 和 lat 和 lon

<iframe
      width="600"
      height="450"
      frameborder="0" style="border:0"
      src="https://www.google.com/maps/embed/v1/view?key=YOUR_API_KEY&center=45.46038,9.18259&zoom=14&maptype=roadmap" allowfullscreen>
    </iframe>
Run Code Online (Sandbox Code Playgroud)

有没有办法像我一样得到一个别针

<iframe
  width="600"
  height="450"
  frameborder="0" style="border:0"
  src="https://www.google.com/maps/embed/v1/place?key=YOUR_API_KEY
    &q=Space+Needle,Seattle+WA" allowfullscreen>
</iframe>
Run Code Online (Sandbox Code Playgroud)

小智 5

根据 Google Maps Embed API 的文档,您在第一个请求中使用的视图模式会返回一个没有标记或方向的地图。

https://www.google.com/maps/embed/v1/view?key=YOUR_API_KEY&center=45.46038,9.18259&zoom=14&maptype=roadmap
Run Code Online (Sandbox Code Playgroud)

为了显示大头针,请将您的模式更改为地点模式,因为地点模式会在特定地点或地址(例如地标、企业、地理特征或城镇)显示地图大头针。

这是我用来显示引脚的代码。

<iframe
width="600"
height="450"
frameborder="0" style="border:0"
src="https://www.google.com/maps/embed/v1/place?key=YOUR_API_KEY&q=45.46038,9.18259&zoom=14&maptype=roadmap" allowfullscreen>
</iframe>
Run Code Online (Sandbox Code Playgroud)