2013-07-01 58 views
1

我遇到了一個問題,我正在開發一個使用phonegap的混合應用程序,並且客戶希望能夠打開本地地圖(適用於iOS的Apple映射和適用於Android的Google Map)用標記,然後在完成時返回到應用程序。在Android上沒關係,後退按鈕已經實現,但是我的問題是針對iOS的。我已經開發了一個小插件來打開本地地圖和地點標記用下面的代碼:打開本地地圖,然後回到應用程序phonegap

CDVPluginResult* pluginResult = nil; 
NSNumber * latN = [command.arguments objectAtIndex:0]; 
NSNumber * lonN = [command.arguments objectAtIndex:1]; 
double lat = [latN doubleValue]; 
double lon = [lonN doubleValue]; 

CLLocationCoordinate2D myCoordinate = CLLocationCoordinate2DMake(lat, lon); 

MKPlacemark *myPlacemark = [[[MKPlacemark alloc] initWithCoordinate:myCoordinate  addressDictionary:nil]autorelease]; 

MKMapItem *mapItem = [[[MKMapItem alloc] initWithPlacemark:myPlacemark]autorelease]; 
mapItem.name = @"My car"; 
[mapItem openInMapsWithLaunchOptions:nil]; 


if (latN != nil && lonN != nil) { 
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"ok"]; 
} else { 
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR]; 
} 

[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; 

有沒有在iOS上執行這個辦法? 在此先感謝, Med。

回答

1

我回來了一個我用在我的案例中的解決方案,經過大量的研究,我發現唯一的方法就是使用mapKit框架。 所以我簡單地使用了cordova MapKit插件(https://github.com/phonegap/phonegap-plugins/tree/master/iOS/MapKit)進行了一些修改,因爲這個版本不是最新的。 我使用地圖視圖和頂部帶有後退按鈕的工具欄設置視圖,因此我們可以訪問本地地圖,然後輕鬆地返回到應用程序。 Med。

相關問題