[英]Display google map in particular view
我希望Google地圖僅顯示在屏幕的一半,而其他項目則顯示在屏幕的另一半。 因此,我將iPhone屏幕分為兩個UIViews: mapView和detailView 。 當我嘗試將Google Map放在mapView內時,它會顯示空白屏幕。 如下圖所示,將地圖分配給self.view時,它將在整個屏幕上顯示地圖。
沒有顯示在mapView中
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
GMSMapView *mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView_.myLocationEnabled = YES;
self.mapView = mapView_; //Doesn't work
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = mapView_;
更改此行:
GMSMapView *mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
對此:
GMSMapView *mapView_ = [GMSMapView mapWithFrame:self.mapView.frame camera:camera];
如果您已經適當地設置了單獨的視圖並且應該與該視圖框架匹配,那應該可以解決您的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.