简体   繁体   English

在新的 Google 地图中嵌入参数

[英]Embed params in new Google Maps

The embed urls produced by the new version of google maps look like this:新版谷歌地图生成的嵌入网址如下所示:

https://www.google.com/maps/embed?pb=!1m5!3m3!1m2!1s0x47b161837e1813b9%3A0x4263df27bd63aa0!2sHamburg%2C+Germany!5e0!3m2!1sen!2s!4v1385644179838

How can I construct such a url programmatically given an address or latitude and longitude?给定地址或纬度和经度,如何以编程方式构建这样的 url?

I wonder if this is the new version or not: https://developers.google.com/maps/documentation/embed/guide我想知道这是否是新版本: https : //developers.google.com/maps/documentation/embed/guide

  1. Address : Add a value following "q=" parameter (The Google Maps Embed API supports both + and %20 when escaping spaces.)地址:在“q=”参数后面添加一个值(Google Maps Embed API 在转义空格时支持 + 和 %20。)

  2. Latitude and longitude : "center=" parameter is for latitude and longitude, but you would also want to set "zoom=" level in order to present in the way how you want it to be displayed to users纬度和经度:“center=”参数用于纬度和经度,但您还需要设置“zoom=”级别,以便以您希望向用户显示的方式呈现

<iframe src="http://maps.google.com/maps?q=pizza+pizza+oshawa&z=10&output=embed" width="100%" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

The magic here is &output=embed .这里的魔法是&output=embed

This is an example using 2 parameters.这是一个使用 2 个参数的示例。 Replace pizza+pizza+oshawa with an url-encoded address and 10 with zoom level you want.用一个 url 编码的地址和10替换你想要的缩放级别的pizza+pizza+oshawa

正如 kjdion84 所建议的,以下工作完美:

<iframe src="http://maps.google.com/maps?q='.$geolat.','.$geolng.'&t=k&z=16&output=embed" width="100%" height="450" frameborder="0" style="border:0" allowfullscreen></iframe>

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

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