【问题标题】:Get google map link with latitude/longitude获取带有纬度/经度的谷歌地图链接
【发布时间】:2013-06-21 19:58:33
【问题描述】:

我想获取谷歌地图链接,该链接在位于纬度/经度的标记中显示标题/内容。

所以参数是标题、内容、纬度、经度。 结果是这样的链接 https://maps.google.com/?ie=UTF8&ll=xxx,xxx&title=xxx&content=xxx

我搜索了谷歌,但在谷歌 API 中没有找到答案、事件。

【问题讨论】:

  • 你要链接还是html代码?

标签: google-maps


【解决方案1】:

我已尝试使用 iframe 执行您需要的请求,以显示所需的纬度、经度和缩放结果:

<iframe 
  width="300" 
  height="170" 
  frameborder="0" 
  scrolling="no" 
  marginheight="0" 
  marginwidth="0" 
  src="https://maps.google.com/maps?q='+YOUR_LAT+','+YOUR_LON+'&hl=es&z=14&amp;output=embed"
 >
 </iframe>
 <br />
 <small>
   <a 
    href="https://maps.google.com/maps?q='+data.lat+','+data.lon+'&hl=es;z=14&amp;output=embed" 
    style="color:#0000FF;text-align:left" 
    target="_blank"
   >
     See map bigger
   </a>
 </small>

【讨论】:

  • 感谢@CroiOS!很高兴知道我的回答对你有用。 @jziwenchen 将不得不决定将我的答案打勾为好答案;)
  • 感谢您的帮助,但这是什么意思? hl=es;z=14
  • @aynaz,“es”是西班牙语,“z”是地图的缩放比例
  • 它不显示标题。所以不应该接受。还在寻找那个。链接如下所示:google.com/maps/embed/v1/place?key=YOURKEY&q=LAT,LON 但正在搜索其他标记设置,例如 &title=Cool Place
  • 这个答案有错别字。它应该是 &amp;z=14 而不是 ;z=14
【解决方案2】:

@vignesh 只有在使用 js 变量时才需要单引号

<iframe src = "https://maps.google.com/maps?q=10.305385,77.923029&hl=es;z=14&amp;output=embed"></iframe>

【讨论】:

    【解决方案3】:

    以上答案都不起作用,但这会。

    <iframe src="'https://maps.google.com/maps?q=' + lat + ',' + lng + '&t=&z=15&ie=UTF8&iwloc=&output=embed'" />
    

    【讨论】:

      【解决方案4】:

      请参阅有关如何使用纬度/经度 here 进行搜索的文档。

      对于指定为的位置:+38° 34' 24.00", -109° 32' 57.00

      https://maps.google.com/maps?q=%2B38%C2%B0+34'+24.00%22,+-109%C2%B0+32'+57.00&ie=UTF-8
      

      请注意,加号 (%2B) 和度数符号 (%C2%B0) 需要正确编码。

      【讨论】:

        【解决方案5】:

        将其保存在 iframe 中,从对象中动态绑定数据。

        "https://www.google.com/maps/embed/v1/place?key=[APIKEY]%20&q=" + content..Latitude + ',' + content.Longitude;

        经度和纬度参考。
        https://developers.google.com/maps/documentation/embed/guide

        注意:[APIKEY] 将在 60 天后过期并重新生成密钥。

        【讨论】:

          【解决方案6】:

          使用查看模式返回没有标记或方向的地图。

          下面的示例使用可选的 maptype 参数来显示地图的卫星视图。

          https://www.google.com/maps/embed/v1/view
            ?key=YOUR_API_KEY
            &center=-33.8569,151.2152
            &zoom=18
            &maptype=satellite
          

          【讨论】:

            【解决方案7】:

            建议的答案在 2014 年之后不再有效。现在您必须使用 Google Maps Embed API 加载到 iframe。

            这里是the link 的问题和解决方案。

            如果您像我一样使用 Angular,由于 XSS 安全问题,您将无法在 iframe 中加载谷歌地图。为此,您需要使用 Pipe from angular 清理 URL。

            这里是the link 这样做。

            截至今天,所有建议都经过测试并且 100% 有效。

            【讨论】:

              【解决方案8】:
                <iframe src="https://maps.google.com/maps?q='+YOUR_LAT+','+YOUR_LON+'&hl=en&z=14&amp;output=embed" width="100%" height="400" frameborder="0" style="border:0" allowfullscreen></iframe>
              

              将您的替换纬度、经度值分别放在 YOUR_LAT、YOUR_LON 上。 hl参数设置地图语言,z为缩放级别;

              【讨论】:

                猜你喜欢
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                • 1970-01-01
                相关资源
                最近更新 更多