Google Maps GMSMarker not appearing on map
As per the Google Map Integration in iOS Swift 3. Adding a Map With Marker.
import UIKit
import GoogleMaps
class ViewController: UIViewController {
override func loadView() {
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
view = mapView
// Creates a marker in the center of the map.
let marker = GMSMarker()
marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
marker.title = "Sydney"
marker.snippet = "Australia"
marker.map = mapView
}
}
GMSMarker not appearing on map
I solved the problem after hours googling. the key is to use Container View inside the mainView and in the containerView initializing the map with these codes:
var camera = GMSCameraPosition.cameraWithLatitude(-33.86,
longitude: 151.20, zoom: 6)
var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
self.map.camera = camera
self.view = mapView
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
marker.title = "title"
marker.snippet = "snippet"
marker.map = mapView
GMSMarker not showing in 1.3
It looks like there is a bug on Google's side. I just stopped using my CustomPlayerAnnotation or GMSMarker, and used a GMSGroundOverlay instead. That showed up on the map. Then instead of using the type, tag, and coordinatePair I built into CustomPlayerAnnotation, I just relied on the title.
playerAnnotation = [[GMSGroundOverlay groundOverlayWithPosition:coord icon:[UIImage imageNamed:@"Down1.png"]] retain];
[playerAnnotation setZoomLevel:zoomLevel];
[playerAnnotation setAnchor:ccp(.5f, 1)];
[playerAnnotation setTitle:@"Player"];
[playerAnnotation setMap:gameMapView];
Side note: notice that I had to setAnchor:ccp(.5f, 1). When it was set to (.5f, .5f) the playerAnnotation overlay would cut off the bottom of the overlay when overlapping other GMSGroundOverlays. Changing the Anchor fixed the z drawing. It looks like 1.4 that just came out may have z-ordering fixed, but 1.4 broke something else on mine so I'll stick with 1.3.1 for now.
swift google maps will not show snippet window
I had to remove the delegate below in order for the infowindow to show.
// func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
// print("marker Tapped")
//
// return true
// }
Related Topics
Does Cidetector for Other Barcode Types
How to Write a Flip Method in Swift
How to Cut a Hole in a Sprite Image or Texture to Show What Is Behind It Using Spritekit in Swift
iOS Coredata Compatible with Both iOS 9 and iOS 10
Add Assets to an Icloud Shared Photo Album Programmatically
How to Check for Self with Contains() in Swift
Getting an Ip Address and Port Number from a Sockaddr_In Struct in Swift
Swift3 Different Font in The All of The UIview with Localization Each
Type Alias Declaration with Templates in Swift
Why My Arguments Are Being Blocked When Running a Shell Command
Swift: Gradient Splits on Rotation
How to Get The Range of The First Line in a String
Swift: Draw a Semi-Sphere in Mkmapview
Automatic Select a Date in Datepicker in Swift Language
How to Remove Items from an Array When Deselecting a Row in a UItableview
How to Import Zbar Framework in Swift Project