我如何用MKMapView打开地图?

时间:2021-09-02 08:39:55

First off, sorry for my english. I have a problem :( I want to open the map of the city. I can use following construction:

首先,对不起我的英语。我有一个问题:(我想打开这个城市的地图。我可以使用以下构造:

NSString *opMap = [[NSString alloc]
initWithFormat:@"http://maps.google.com/maps?q=new+york+21st+street"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:opMap]];
[opMap release];

But, this - map opens up Safari. I want to open this address (for example New York 21st street(in reality - this address will be provided by a server) with MKMapView. How I can do that?

但是,这个 - 地图打开了Safari。我想用MKMapView打开这个地址(例如纽约21街(实际上这个地址将由服务器提供)。我怎么能这样做?

2 个解决方案

#1


0  

You can use geocoding and MKMapView. http://files.mettigel-software.com/TSGeocoder.zip is a sample code from my bookmarks, it uses google services. But I am not sure if it violates google's TOS or not.

您可以使用地理编码和MKMapView。 http://files.mettigel-software.com/TSGeocoder.zip是我书签的示例代码,它使用谷歌服务。但我不确定它是否违反谷歌的服务条款。

You should just geocode the address and than show latitude and longitude in MKMapView.

您应该只对地址进行地理编码,然后在MKMapView中显示纬度和经度。

#2


0  

Well, you can open the google maps URL and read the returned HTML and find the string '\x26ll='. What follows that is the lat/lon pair, comma separated.

好吧,您可以打开谷歌地图网址并阅读返回的HTML并找到字符串'\ x26ll ='。接下来是lat / lon对,逗号分隔。

#1


0  

You can use geocoding and MKMapView. http://files.mettigel-software.com/TSGeocoder.zip is a sample code from my bookmarks, it uses google services. But I am not sure if it violates google's TOS or not.

您可以使用地理编码和MKMapView。 http://files.mettigel-software.com/TSGeocoder.zip是我书签的示例代码,它使用谷歌服务。但我不确定它是否违反谷歌的服务条款。

You should just geocode the address and than show latitude and longitude in MKMapView.

您应该只对地址进行地理编码,然后在MKMapView中显示纬度和经度。

#2


0  

Well, you can open the google maps URL and read the returned HTML and find the string '\x26ll='. What follows that is the lat/lon pair, comma separated.

好吧,您可以打开谷歌地图网址并阅读返回的HTML并找到字符串'\ x26ll ='。接下来是lat / lon对,逗号分隔。