Simple Question
I´m working on an App for iOS where I embedded the new Google Map for native iOS. Everything works fine except one problem where I can´t find a propp
Create one subview which you want to show in infoWindow.
Set frame of subview equals to frame of infoWindow view.
subView = [[[NSBundle mainBundle] loadNibNamed:@"viewName" owner:self options:nil] objectAtIndex:0];
[subView setFrame:infoview.frame];
[self.mapview addSubview:subView];
get information at google map view information
func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {
print(marker.title!)
print(marker.snippet!)
}
1.conform to the GMSMapViewDelegate
protocol.
@interface YourViewController () <GMSMapViewDelegate>
// your properties
@end
2.set your mapView_
delegate.
mapView_.delegate = self;
3.implement the GMSMapViewDelegate
method
- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker {
// your code
}
btw, marker.userData
is useful. you can set your needed data into it and use it in - mapView:didTapInfoWindowOfMarker:
You can use GMSMapViewDelegate
with:
mapView.delegate = self
func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {
print("InfoView tapped")
}
a full answer for swift 4
add GMSMapViewDelegate
as delegate
set yourmap delegate like this : googlemap.delegate = self
add this func
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool { // do something return true }
where you adding Map,add
mapView_.delegate=self;
then use this
-(void)mapView:(GMSMapView *)mapView
didTapInfoWindowOfMarker:(id<GMSMarker>)marker{
//info window tapped
}