如何将参数传递给 URL 并获取生成的图像
我想将几个参数传递给这个 url 并从中生成地图并在我的 java 应用程序中显示它。我知道下载图像并在java应用程序中显示它的代码。我想知道如何将参数传递到这个地址:
在此链接中,Nugegoda、Mirihana 和 Udahamulla 是我应该从申请中通过的链接。然后它会生成一个图像,我确实需要显示它。即使你检查这个链接。这是一个图像。
有人可以帮助我吗?
I want to pass several parameters to this url and generate the map from it and show it in my java application. I know the code to download the image and show it in the java application. I want to know how to pass parameters to this address:
In this link Nugegoda and Mirihana and Udahamulla is the one that i should pass from the application. And then it will generate a image and i do need to show it. Even if u check this link. It's a image.
Can someone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
静态地图 API 可以执行地理编码 如果您将有效地址传递给
center
参数:您可以传递的参数都是列于此处。按照 URL 的标准,所有参数均使用与号
&
字符分隔。因此,如果您想添加maptype
参数并将其设置为hybrid
,例如,您只需在上面添加&maptype=hybrid
即可网址:然后,如果您想显示 Udahamulla 地图,只需将 Nugegoda 替换为 Udahamulla 即可
center
参数:更新:
除了下面的评论之外,您可以使用 < code>path 参数,如下:
请注意 API 如何对地址“Maharagama”和“Nugegoda”进行地理编码,因此您无需传递地点的纬度和经度坐标。
目前,静态地图 API 不提供行车路线指示。不过,如果您有复杂路线的点,则可以将路径绘制为编码的折线。
The Static Maps API can do geocoding for you if you pass a valid address to the
center
parameter:The parameters that you can pass are all listed here. As is standard in URLs, all parameters are separated using the ampersand
&
character. Therefore if you want to add themaptype
parameter and set it tohybrid
for example, you can simply add&maptype=hybrid
to the above URL:Then if you want to show the Udahamulla map, simply replace Nugegoda with Udahamulla for the
center
parameter:UPDATE:
Further to the comments below, you can add a polyline on a static map by using the
path
parameter, as follows:Note how the API geocodes the addresses "Maharagama" and "Nugegoda", so you do not need to pass the latitude and longitude coordinates of the localities.
Currently the Static Maps API does not do driving directions. However if you have the points of a complex route, you could plot the path as an encoded polyline.
您可以使用 Google 静态地图 API。如果你纯粹想插入变量,你可以这样做:
You can use the Google Static Maps API. If you purely want to interpolate variables, you can do:
您的问题是“如何构造一个包含一些可变部分的字符串?”当您在应用程序中构建 URL 字符串时,它“只是”一个字符串。您可以连接不同的部分,或使用格式化打印。 (请参阅格式。)
(给定的 URL 已经有许多参数:问号后面的每一对都是变量名称和值。)
Is your question "How do I construct a String that has some variable parts in it?" At the time you build the URL string in your application, it is 'just' a String. You can concatenate the different parts, or use formatted printing. (See format.)
(The URL given already has a number of parameters: every pair behind the question mark is a variable name and value.)