我的代码如下:
/* Map */
mapView = GMSMapView()
mapView.delegate = self
mapView.mapType = .normal
do {
// Set the map style by passing the URL of the local file.
if let styleURL = Bundle.main.url(forResource: "styles", withExtension: "json") {
mapView.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
} else {
NSLog("Unable to find styles.json")
}
} catch {
NSLog("One or more of the map styles failed to load. \(error)")
}
我正在关注 this有关如何自定义我的 Google map 的教程。
以上是我实现 styles.json 文件的代码。我在我的构建包中添加了该文件,并且代码从未抛出关于无法解析我的 json 文件的异常。它根本没有将样式效果应用到我的 map 上。
如有任何帮助,我们将不胜感激。我在里面慢慢地死去!!!
最佳答案
为 future 任何人留下答案:
Google map 样式不适用于韩国 map 。它甚至适用于朝鲜,但不适用于韩国。韩国法律禁止将 map 数据导出到国外数据中心。
source :
Yes , Korea does not support some features offered by Google Map due to national law. Google Map Korea can not be export map data for data centers abroad or including the ability to dynamically change the map image. Many South Korea Maps and services are limited to the domestic uses and Google is striving to make this a better service. For more details here's the original answer in Korean: original reply from Google Maps Korea
关于ios - 无法将样式应用于 GMSMapView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46335889/