如何使用Google静态图片映射添加InfoWindow对象?

问题描述 投票:6回答:1

我想向从静态Google图片API获取的图片添加文本标签。就像在简单的Google地图中所有标记的标签和信息窗口一样。

我看过文档,但文档记录不清晰。是否可以在google Static Image API中显示一个信息窗口。

google-static-maps
1个回答
0
投票

当前,M​​arker标签或InfoWindows尚不可用于Google Maps Platform-Maps Static API。

但是,我们在Google Issue Tracker中确实有对此功能的要求。为了表达您的兴趣并订阅其最新更新,建议您为该条目添加星号:https://issuetracker.google.com/35818346

同时,请注意,通过使用已经具有标签的Custom Icons,您可以实现类似的效果。但是,此解决方案可能会花费很多时间,因为您首先必须编辑将用于包含标签的图标图像,然后将其托管在某个位置。

请参阅以下示例请求:http://maps.googleapis.com/maps/api/staticmap?size=600x400&markers=icon:https://raw.githubusercontent.com/annkylah/TestRepo/master/icon2.png|anchor:26,68|scale:2|-35.281454,149.128545&markers=icon:https://raw.githubusercontent.com/annkylah/TestRepo/master/icon1.png|anchor:26,68|scale:2|-37.936915,145.169723&markers=icon:https://raw.githubusercontent.com/annkylah/TestRepo/master/icon3.png?raw=true|anchor:26,68|scale:2|-33.842312,150.983470&key=YOUR_API_KEY

Sample Static Map

之前也可以使用Google Charts - Image Charts,但是,此服务已于2019年3月18日被关闭。

您还应注意“自定义图标”的限制解决方法是you could only specify up to five unique custom icons per Maps Static API request。Google问题跟踪工具向allow more than 5 custom icons提交了功能请求但是,它被标记为另一个feature request to support KML layers in Static Maps API的副本。

我希望这会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.