gpt4 book ai didi

ios - 如何从 iOS 中的谷歌地图获取静态图像

转载 作者:搜寻专家 更新时间:2023-10-30 21:48:29 24 4
gpt4 key购买 nike

我使用适用于 iOS 的 google maps api。我想获取特殊城市的静态图像并将其粘贴到 UIImageView 中。我怎样才能做到?

最佳答案

@Ankit 的回复是正确的,但是@Alexsander 在 Swift 中询问,所以:

var staticMapUrl: String = "http://maps.google.com/maps/api/staticmap?markers=color:blue|\(self.staticData.latitude),\(self.staticData.longitude)&\("zoom=13&size=\(2 * Int(mapFrame.size.width))*\(2 * Int(mapFrame.size.height))")&sensor=true"
var mapUrl: NSURL = NSURL(string: staticMapUrl.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding))!
var image: UIImage = UIImage.imageWithData(NSData.dataWithContentsOfURL(mapUrl))
var mapImage: UIImageView = UIImageView(frame: mapFrame)

for swift 4

let staticMapUrl: String = "http://maps.google.com/maps/api/staticmap?markers=\(self.finalLatitude),\(self.finalLongitude)&\("zoom=15&size=\(2 * Int(imgViewMap.frame.size.width))x\(2 * Int(imgViewMap.frame.size.height))")&sensor=true"

let mapUrl: NSURL = NSURL(string: staticMapUrl)!
self.imgViewMap.sd_setImage(with: mapUrl as URL, placeholderImage: UIImage(named: "palceholder"))

关于ios - 如何从 iOS 中的谷歌地图获取静态图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34851795/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com