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. (It doesn't matter which stlye attributes are set or not set it always happens for me)
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. The app looks like this:
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:
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:
[
{
"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. The Map then looks like this: (like mentioned this doesn't happen if no style gets applied)
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?
If you need further informations let me know i will provide everything you need.
Best Regards.
