2013-04-21 72 views
0

谷歌地图1.2.0GMSCoordinateBounds现在包含一个containsCoordinate方法,我打算用它来过滤不在visibleRegion上的标记。不幸的是,当你初始化一个GMSCoordinateBounds时,你会得到包含你的区域或路径的界限。如何查看GMSPath是否包含坐标

所以我的问题是:是否有可能看到CLLocationCoordinate2D是否在GMSPath

回答

0

所以我回答我自己的问题。我只需要使用pointForCoordinate方法来查看点是否在屏幕上。完美的作品。

for (int i = 0; i < self.visibleLocations.count; i++) { 
     Location *location = [self.visibleLocations objectAtIndex:i]; 
     CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([location.lat floatValue], [location.lng floatValue]); 
     CGPoint markerPoint = [self.googleMap.projection pointForCoordinate:coordinate]; 
     if (markerPoint.x >= 0 && markerPoint.y >= 0 && markerPoint.x <= self.googleMap.frame.size.width && markerPoint.y <= self.googleMap.frame.size.height) { 
      GMSMarker *marker = [GMSMarker markerWithPosition:coordinate]; 
      marker.title = location.title; 
      marker.icon = [UIImage imageNamed:@"search_measle_small.png"]; 
      marker.map = self.googleMap; 
     } 
    } 
相关问题