How to show a Info window in iOS Google maps without tapping on Marker?
GMSMarkerOptions *myLocationOptions = [GMSMarkerOptions options];
myLocationOptions.title = @"My Location";
myLocationOptions.snippet = @"Lat:...., Lang:....";
mapView.selectedMarker = [mapView addMarkerWithOptions:myLocationOptions];
(note that it's Options, not Option)
How to show all Info window in iOS Google maps without tapping on Marker?
you can display one InfoWindow at a time.
mapView.selectedMarker = marker; this will open the infowindow for the last marker
If you want to show multiple markers then you should make marker that contains both the marker and the info window .
Hope this helps.
How to tap on ios google map marker programatically or show info window of marker?
Providing map to the marker is essential
For Obj c
GMSMarker *myMarkerAutomaticSnippet = [[GMSMarker alloc] init];
marker.position = <Your cordinates>;
marker.title = @"my Title";
marker.snippet = @"my Snippet";
marker.map = myCustomMapView;
[myCustomMapView setSelectedMarker:marker];
For Swift 3.0
let myMarker = GMSMarker()
myMarker.position = CLLocationCoordinate2DMake(80.0, 80.0)
myMarker.title = "marker title"
myMarker.snippet = "marker snippet"
myMarker.map = customMap // Here custom map is your GMSMapView
customMap.customMapView.selectedMarker = myMarker // This line is important which opens the snippet
Google map ios sdk info window only appear on 2 taps
try writing this delegate :
- (BOOL)mapView:(GMSMapView*)mapView didTapMarker:(GMSMarker*)marker
{
[mapview setSelectedMarker:marker];
return YES;
}
Displaying info window when tapped marker in google maps iOS sdk while implementing mapView:didTapMarker: delegate method implemented
Implement GMSMapViewDelegate
's mapView:didTapMarker:
method and make it return false
.
Swift Implementation:
func mapView(mapView: GMSMapView!, didTapMarker marker: GMSMarker!) -> Bool {
return false
}
Hide Google Map info window when map is moved with Swift
You could make your UIViewController
conform to GMSMapViewDelegate
and then implement one of the methods listed here: https://developers.google.com/maps/documentation/ios-sdk/reference/protocol_g_m_s_map_view_delegate-p
I guess the first one (mapView:willMove:
) would work for you. I would use a print statement (or breakpoint) to check, whether the method is triggered as expected. To hide the current info window, you should be able to set mapView.selectedMarker = nil
.
To sum up, your code might look like this:
import UIKit
import GoogleMaps
class ViewController: UIViewController {
//declare your map, etc.
override func viewDidLoad() {
super.viewDidLoad()
// setup your map
}
}
extension ViewController: GMSMapViewDelegate {
func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
if gesture { //The map was moved by the user
//mapView.selectedMarker = nil
}
}
}
Programmatically display a GMSMarker's info window
After going on google's issue tracker and submitting a post, I found out that mapView.selectedMarker() = marker
does not actually have any connection to the mapView(didTap:)
delegate method, so returning true
in the delegate method has no impact on the selectedMarker()
method's functionality.
As a result I can just add mapView.selectedMarker() = marker
in the delegate method after customizing the location I want to animate the mapView to and before returning true
, which causes the marker's info window to pop up without messing with the camera position.
Related Topics
How to Check If a Uialertcontroller Is Already Presenting
iOS Provisioning and Certifcates - Will Revoke/Renew Effect App Store Apps
How to Push Two View Controllers But Animate Transition Only for the Second One
Pod Error in Xcode "Id: Framework Not Found Pods"
Spacing Between Uitableviewcells
How to Set an Title of the Currently Playing Audio in iPhone Lock Screen
Nsstring Containsstring Crashes
Upload Multiple Images in Swift Using Alamofire
Opengl Es 2.0 Object Picking on iOS
Nsarray with Nspredicate Using Not In
How to Rotate an Uiimageview by 20 Degrees
Nsurlsession "Http Load Failed Kcfstreamerrordomainssl, -9813 ; Self Signing Certificate
Tableview:Numberofrowsinsection:]: Unrecognized Selector Sent to Instance