xcode IOS google maps sdk 中的自定义信息窗口
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25599791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Custom info window in IOS google maps sdk
提问by gerhard
being a newby IOS developer, I'm really struggling to get something basic to work.
作为 IOS 开发人员的新手,我真的很难获得一些基本的工作。
I have a need to display this kind of custom info window upon a marker click in the google maps sdk for ios.
我需要在 google maps sdk for ios 中单击标记时显示这种自定义信息窗口。
Any help would be appreciated.
任何帮助,将不胜感激。
I've already seen the third party components, but even with them I cannot get this to display. There is always a title, snippet, left image and right image part. The real question is how do you get the gold star rating in the window, with the text next to it.
我已经看到了第三方组件,但即使使用它们,我也无法显示它。总是有一个标题、片段、左图和右图部分。真正的问题是如何在窗口中获得金星评级,并在其旁边显示文本。
采纳答案by gerhard
ended up using SMCalloutView @ https://github.com/nfarina/calloutview
最终使用 SMCalloutView @ https://github.com/nfarina/calloutview
回答by Dipen Desai
Make Xib as you want...set Text and image
根据需要制作 Xib...设置文本和图像
set delegate GMSMapViewDelegate
设置委托GMSMapViewDelegate
-(UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker{
CustomInfoWindow *infoWindow=[[[NSBundle mainBundle] loadNibNamed:@"InfoWindow" owner:self options:nil] objectAtIndex:0];
return infoWindow;
}
https://www.youtube.com/watch?v=ILiBXYscsyYfor more help see this video..Uploded by google
https://www.youtube.com/watch?v=ILiBXYscsyY如需更多帮助,请观看此视频..由 google 上传
回答by Naresh Reddy M
I was suffering from the same problem of Info window customization in GoogleMapsSdk for iOS for a lot of days, got frustrated & did it my self!
我在 iOS 版 GoogleMapsSdk 中遇到了同样的信息窗口自定义问题很多天了,感到沮丧并自己完成了!
Clean, Completely customizable & Own UIControls with your custom actions code can be found on Github Right here
可以在 Github 上找到带有自定义操作代码的干净、完全可定制和拥有的 UIControls 就在这里
Happy coding :)
快乐编码:)
回答by Sourabh Sharma
Swift 3.0 Solution
Swift 3.0 解决方案
Google Map CustomInfoWindow
谷歌地图自定义信息窗口
//empty the default infowindow
func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
return UIView()
}
// reset custom infowindow whenever marker is tapped
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
customInfoView.removeFromSuperview()
// customInfoView.button.addTarget(self, action: #selector(buttonTapped(_:)), for: .touchUpInside)
self.view.addSubview(customInfoView)
// Remember to return false
// so marker event is still handled by delegate
return false
}
// let the custom infowindow follows the camera
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
if (locationMarker != nil){
let location = locationMarker.position
customInfoView.center = mapView.projection.point(for: location)
}
}
// take care of the close event
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
customInfoView.removeFromSuperview()
}