gpt4 book ai didi

ios - 实现 Google map 样式向导 JSON

转载 作者:搜寻专家 更新时间:2023-10-31 08:16:21 25 4
gpt4 key购买 nike

我用 Styling Wizard 自定义了谷歌地图的外观.它告诉我复制 JSON,我照做了,但我不知道在我的 iOS Swift 项目 中的什么地方实现它。

有人知道放在哪里吗?
谢谢!

最佳答案

您可以使用这段代码来创建时尚的 map ,您已经在其中创建了 GoogleMaps 对象 mapView

Swift 3.x code

do {
// Set the map style by passing the URL of the local file. Make sure style.json is present in your project
if let styleURL = Bundle.main.url(forResource: "style", withExtension: "json") {
mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
} else {
print("Unable to find style.json")
}
} catch {
print("The style definition could not be loaded: \(error)")
}

您作为样式向导发布的链接将用于创建 json 文件。修改您的 map 并创建一个 json。然后复制 json 并创建一个新的纯文本文件并粘贴 json。给文件名 style.json。复制项目中的 .json 文件并使用上面的代码更改 map 的样式。检查这个Link了解更多详情。

查看我的结果输出。我创建了一张银色 map 。

enter image description here

关于ios - 实现 Google map 样式向导 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40059366/

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