- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我得到了 MKLocalSearch
的结果,它包括类似...
{
address = {
formattedAddressLine = (
"Marton Road",
Middlesbrough,
TS1,
England
);
structuredAddress = {
administrativeArea = England;
areaOfInterest = (
"Great Britain"
);
country = "United Kingdom";
countryCode = GB;
fullThoroughfare = "Marton Road";
geoId = (
);
locality = Middlesbrough;
postCode = TS1;
subAdministrativeArea = Middlesbrough;
thoroughfare = "Marton Road";
};
};
addressGeocodeAccuracy = 0;
business = (
{
UID = 9301704419119613323;
URL = "http://www.cineworld.co.uk";
attribution = (
{
attributionURLs = (
"yelp5.3:///biz/cineworld-middlesbrough",
"yelp4:///biz/cineworld-middlesbrough",
"yelp:///biz/cineworld-middlesbrough",
"http://yelp.com/biz/cineworld-middlesbrough"
);
sourceIdentifier = "com.yelp";
sourceVersion = 1;
}
);
canBeCorrectedByBusinessOwner = 1;
name = Cineworld;
source = (
{
"source_id" = "b2LOPag6ha6845__dgXehw";
"source_name" = yelp;
},
{
"source_id" = 6670;
"source_name" = tribune;
},
{
"source_id" = 2000000103009680;
"source_name" = "acxiom_intl";
},
{
"source_id" = "cineworld-middlesbrough";
"source_name" = "yelp_alias";
}
);
"star_rating" = (
0
);
telephone = "+448712002000";
}
);
center = {
lat = "54.57633773904653";
lng = "-1.228197113614671";
};
inputLanguage = en;
localSearchProviderID = 9902;
mapRegion = {
eastLng = "-1.224891596539819";
northLat = "54.57545000290778";
southLat = "54.5738619816233";
westLng = "-1.227631256834202";
};
name = Cineworld;
type = 57;
}
现在,当我使用...将其添加到我的 map 时
id <MKAnnotation> annotation = mapItem.placemark;
[self.mapView addAnnotation:annotation];
它添加了一个图钉,当我点击它时会显示“Marton Road”,但我希望它显示“Cineworld”。
不过,我发现很难找到任何关于从 MKMapItem
中获取东西并放入 MKPlacemark
中的信息。
如果我尝试在地标中使用 mapItem.name
,那么它们都会显示“美国”。
知道如何从中获得一些更有用的信息吗?
最佳答案
MKPlacemark
返回其 title
属性的地址,MKPlacemark
类不允许您设置 title
你自己。
你可以做的是创建一个 MKPointAnnotation
(它有一个可设置的 title
属性)并将它的 title
设置为你想要的任何东西 mapItem.name
.
例如:
MKPointAnnotation *pa = [[MKPointAnnotation alloc] init];
pa.title = mapItem.name;
pa.coordinate = mapItem.placemark.coordinate;
[self.mapView addAnnotation:pa];
注意:
您不必使用 MKPointAnnotation
类(它只是最方便的可用类)。
您还可以使用符合 MKAnnotation
且具有可设置的 title
属性的自定义类(或某些返回 MKMapItem
的 name
作为它的 title
)。
另请注意,如果您希望能够在事后添加的注释中访问相关的 MKMapItem
或 MKPlacemark
(例如,在 map View 中委托(delegate)方法),您需要使用自定义类而不是 MKPointAnnotation
,在其中添加可以在创建注释时设置的“sourceMapItem”或“sourcePlacemark”属性。
这样,您可以根据需要设置 title
,但仍然可以访问注释对象所在的所有原始 MKMapItem
或 MKPlacemark
值创建(如果仅使用 MKPointAnnotation
,则无法轻松完成此操作,因为它不保留对源 map 项或地标的引用)。
关于ios - MKMapItem 没有在 MKPlacemark 上显示正确的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25532687/
我正在使用 Gunicorn 为 Django 应用程序提供服务,它工作正常,直到我将其超时时间从 30 秒更改为 900000 秒,我不得不这样做,因为我有一个用例需要上传和处理一个巨大的文件(过程
我有一个带有非常基本的管道的Jenkinsfile,它可以旋转docker容器: pipeline { agent { dockerfile { args '-u root' } } stag
在学习 MEAN 堆栈的过程中,我遇到了一个问题。每当我尝试使用 Passport 验证方法时,它都不会返回任何响应。我总是收到“localhost没有发送任何数据。ERR_EMPTY_RESPONS
在当今的大多数企业堆栈中,数据库是我们存储所有秘密的地方。它是安全屋,是待命室,也是用于存储可能非常私密或极具价值的物品的集散地。对于依赖它的数据库管理员、程序员和DevOps团队来说,保护它免受所
是否可以创建像图片上那样的边框?只需使用 css 边框属性。最终结果将是没 Angular 盒子。我不想添加额外的 html 元素。我只想为每个 li 元素添加 css 边框信息。 假设这是一个 ul
我是一名优秀的程序员,十分优秀!