[英]GMSMapView city labels disappearing
Summary: 摘要:
When using the GMSMapView
object from the GoogleMaps framework (installed per pods from here: https://cocoapods.org/pods/GoogleMaps ) i have a strange issue when applying a custom mapstyle to the GMSMapView
- the city and country labels are disappearing - this doesn't happen when i don't use any custom style for the map. 当使用来自GoogleMaps框架的
GMSMapView
对象(从这里安装每个pod: https ://cocoapods.org/pods/GoogleMaps)我将自定义mapstyle应用到GMSMapView
时出现了一个奇怪的问题 - 城市和国家标签正在消失 -当我不为地图使用任何自定义样式时,这不会发生。 (It doesn't matter which stlye attributes are set or not set it always happens for me) (设置或不设置哪个stlye属性并不重要,它总是发生在我身上)
Steps to reproduce: 重现步骤:
I reproduced my issue in a Single View Application with only one ViewController where the map is constraint in Storyboard and linked to my ViewController.swift. 我在单视图应用程序中重现了我的问题,只有一个ViewController,其中地图是Storyboard中的约束并链接到我的ViewController.swift。 The app looks like this:
该应用程序如下所示:
AppDelegate: AppDelegate中:
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let myGoogleMapsAPIKey: String = "[here goes my API-Key]"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GMSServices.provideAPIKey(self.myGoogleMapsAPIKey)
return true
}
func applicationWillResignActive(_ application: UIApplication) {}
func applicationDidEnterBackground(_ application: UIApplication) {}
func applicationWillEnterForeground(_ application: UIApplication) {}
func applicationDidBecomeActive(_ application: UIApplication) {}
func applicationWillTerminate(_ application: UIApplication) {}
}
ViewController.swift : ViewController.swift :
class ViewController: UIViewController {
// mapView is linked from storyboard
@IBOutlet weak var mapView: GMSMapView!
override func viewDidLoad() {
super.viewDidLoad()
self.applyStyleToMap(self.mapView)
}
func applyStyleToMap(_ map: GMSMapView) {
do {
if let styleURL = Bundle.main.url(forResource: "mapStyle", withExtension: "json") {
map.mapStyle = try GMSMapStyle(contentsOfFileURL: styleURL)
} else {
NSLog("Unable to find mapStyle.json")
}
} catch {
NSLog("Map style failed to load")
}
}
}
mapStyle.json: mapStyle.json:
[
{
"featureType": "administrative.locality",
"elementType": "all",
"stylers": [
{
"visibility": "on"
}
]
}
]
Issue: 问题:
When zooming with a Pinch-Gesture into and out of the GMSMapView
at specific zoom stages all labels are disappearing from the map with custom style. 当使用捏合手势在特定缩放阶段进出
GMSMapView
,所有标签都会从具有自定义样式的地图中消失。 The Map then looks like this: (like mentioned this doesn't happen if no style gets applied) Map然后看起来像这样:(如果没有应用样式,这就不会发生这种情况)
Did anyone experience this is issue and can point me in the right direction? 有没有人遇到这个问题,可以指出我正确的方向? Am i missing a thing or is it a bug in the Google-Maps-iOS-SDK?
我错过了什么,或者它是Google-Maps-iOS-SDK中的错误?
If you need further informations let me know i will provide everything you need. 如果您需要进一步的信息,请告诉我我将提供您需要的一切。
Best Regards. 最好的祝福。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.