- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想知道是否可以使用 Map Kit 仅在 map 上显示特定区域而不是完整的世界地图。就像如果我想在我的应用程序中显示亚洲 map , map 工具包会隐藏 map 的剩余部分。
最佳答案
要处理“ map 工具包隐藏 map 的剩余部分”要求,您可以做的一件事是创建一个覆盖整个世界的黑色多边形叠加层,并在亚洲(或您喜欢的任何地方)上进行裁剪。
例如,您在何处初始化 map (例如,在 viewDidLoad 中):
CLLocationCoordinate2D asiaCoords[4]
= { {55,60}, {55,150}, {0,150}, {0,60} };
//change or add coordinates (and update count below) as needed
self.asiaOverlay = [MKPolygon polygonWithCoordinates:asiaCoords count:4];
CLLocationCoordinate2D worldCoords[4]
= { {90,-180}, {90,180}, {-90,180}, {-90,-180} };
MKPolygon *worldOverlay
= [MKPolygon polygonWithCoordinates:worldCoords
count:4
interiorPolygons:[NSArray arrayWithObject:asiaOverlay]];
//the array can have more than one "cutout" if needed
[myMapView addOverlay:worldOverlay];
并实现 viewForOverlay
委托(delegate)方法:
-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)overlay
{
if ([overlay isKindOfClass:[MKPolygon class]])
{
MKPolygonView *pv = [[[MKPolygonView alloc] initWithPolygon:overlay] autorelease];
pv.fillColor = [UIColor blackColor];
pv.alpha = 1.0;
return pv;
}
return nil;
}
看起来像这样:
如果您还想限制用户滚动到亚洲以外或缩小得太远,那么您也需要手动执行此操作。 Restrict MKMapView scrolling 中描述了一种可能的方法.将该答案中的 theOverlay
替换为 asiaOverlay
。
关于iphone - 使用 MapKit 显示特定区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8679499/
我想在我的应用程序中显示 map 上两点之间的点对点路线。我正在使用 MKDirectionsRequest为此。我试图找到浦那到孟买之间的路线。我收到一个错误作为响应。 错误消息: Error Do
我想我可能在 iOS 6 的 mapkit API 中发现了一个错误,但由于我仍然认为自己是新手,我想我会在这里查看是否有人能指出我可能做错的事情。 我有一个应用程序已经工作了几个星期,其中有一个 m
这是我的第一个程序。而且,我正在实现 MapKit。以下是代码: import UIKit import MapKit class ViewController: UIViewController {
如何从 MapkitView 获取当前可见叠加层的列表(数组)? 背景 - 例如,我想在我的 mapkitview 上显示指向某些覆盖类型中心的方向箭头,但是如何获得可见的箭头?我看似乎没有办法做到这
我使用了 Apples WWDC 2017 的项目 tandm - 237“Mapkit 中的新功能”。 已经有一个带数组的data.plist命名的自行车和额外的词典有四个项目(键:值 - 对)。
我正在使用 iOS 11 集群,它工作得很好,基本上你只需要将标识符添加到 MKAnnotationView 的 clusteringIdentifier 属性。 一切正常,但我有一个问题,当用户从
我有一个MKMapView,在顶部有一个UISearchBar,我希望用户能够键入一个地址,并找到该地址并在其上放一个别针。我不知道如何将地址字符串转换为经度和纬度,因此我可以创建一个CLLocati
我想在 map 上画一条路线。 但不使用委托(delegate)的结构。 struct MapView : UIViewRepresentable { } func mapView(_ mapView
绘制的折线显示在建筑物下方。 如何使折线位于所有图层的顶部 请建议 将折线添加为 var coordinates = locationsArrToAdd.map({ (location: CLL
我有一个简单的 Mac 应用程序,不打算用于任何类型的分发;只是个人使用。该应用程序是 NSWindow其中包含一个 MKMapView .由于我没有 Mac 开发人员帐户,也不想要(请参阅“仅供个人
这是一个非常简单的问题。在 MapKit JS 中,如何将注释设置为选中的注释? 我已经在 map View 上有了注释并且可以访问我想要选择的注释。我觉得应该有一个类似于 MapKit 的方法(不是
我可以在我的应用程序中使用 Google map 街景吗? 最佳答案 不。 [填充字符以克服可疑的最小值] 关于xcode - MapKit 是否允许街景?,我们在Stack Overflow上找到一
我有一个功能,可以将注释放大到 map 上的一半,以及用户的位置,这样两者都可以在屏幕上看到。是否有显示其“内容”的注释方法,即模拟按下它?它在放大后立即弹出是理想的选择。 提前致谢。 最佳答案 您可
在我的应用程序中,我添加了很多引脚,并在 viewForAnnotaion 中,我在 MKPinAnnotaionView 上设置了 animatesDrop=TRUE。问题是,当有 200 多个引脚
我已经为此苦苦挣扎了几天,我什至重写了一半的代码来尝试另一种方式。 我从 csv 导入了注释,并用图 block 和副标题放置在 map 上,我徒劳地尝试添加一个标签来公开按钮,以便我可以看到点击了哪
我按照本教程制作了我的第一个应用程序: http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/ 我真的很想知道
我是 iPhone 开发新手。我在 map 上添加了注释。我能够在 didSelectAnnotationView() 中捕获注释上的点击事件。但我想在用户点击注释时更改注释的图像。 最佳答案 设置图
所以我的 map 上散布了一堆注释...一切都很漂亮。现在我需要能够设置 map 的位置和缩放,以便它们完美契合。我怎样才能做到这一点? 最佳答案 来自苹果论坛... - (void)recenter
我是 iPhone 版 MapKit 的新手,尝试实现此功能,由于某种原因我看不到当前位置蓝点,其他人也有这个问题吗??? #import "DetailMapViewController.h" #i
我有一张显示多个注释的 map 。我想模仿“照片”内置应用程序(iOS 4)上“位置”选项卡的行为,其中当用户更改缩放级别时,注释会自动连接在一起或分开。 我该怎么做? 谢谢! 最佳答案 “照片”应用
我是一名优秀的程序员,十分优秀!