【发布时间】:2014-11-19 00:26:48
【问题描述】:
当我点击一个标记时,我想快速显示一个包含基本信息的信息窗口,然后调用一个网络服务来返回我到标记的距离/路径。
我必须调用网络服务,而不是直接调用 Google Maps SDK,因为路径已修改为到达某些点。
我试过那个代码:
- (void)fillInfoWindowForMarker:(GMSMarker *)marker {
// get infos
NSURL * url = [WSHelper.sharedHelper getPathURLForOrigin:origin destination:dest inGreenPath:greenPath];
NSDictionary * result = [WSHelper.sharedHelper getPathAtUrl:url];
GMSPath * path = [result valueForKey:@"path"];
NSString * distance = [result valueForKey:@"distance"];
dispatch_async(dispatch_get_main_queue(), ^{
pathLine = [GMSPolyline polylineWithPath:path];
pathLine.strokeWidth = 2;
pathLine.strokeColor = UIColor.blackColor;
pathLine.map = map;
infoWindow.distanceLabel.text = @"something"
});
}
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
if (infoWindow) {
pathLine.map = nil;
infoWindow = nil;
pathLine = nil;
}
InfoWindowView * view = [[[NSBundle mainBundle] loadNibNamed:@"InfoWindowView" owner:self options:nil] objectAtIndex:0];
view.distanceLabel.text = @"0 km";
infoWindow = view;
view.tag = 678;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
[self fillInfoWindowForMarker:marker];
});
return view;
}
其中infoWindow 是我的控制器的UIView 子类属性。
在地图上绘制了路径,但标签没有更新。我试图打印地图子视图,但里面没有InfoWindow。
我怎么能做到这一点?
【问题讨论】:
标签: objective-c google-maps-sdk-ios