使用apache cordova 2.1构建ios应用程序。建筑和造型很好,但地图不是。
我找到了地图的插件,但根本无法让它工作: https://github.com/phonegap/phonegap-plugins/tree/master/iOS/MapKit
我还找到了一个示例html文件但可以: https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/MapKitPlug/example
1 / 所以我将MapKit框架添加到xcode中,这非常简单: http://blog.thinketg.com/blog/david-brainer-banker/xcode-4-tips-adding-frameworks-to-your-project
2 / 添加了.m和.h文件
3 / 添加了.js文件并将其链接到我的index.html
4 / 复制了上面的示例html。
5 / 根据说明
将Mapkit添加到.plist文件中当我尝试运行地图时,我收到以下错误:
2012-11-05 14:21:29.505 sawdaysApp[25398:c07] Multi-tasking -> Device: YES, App: YES
2012-11-05 14:21:30.895 sawdaysApp[25398:c07] CDVPlugin class MapKitView (pluginName: MapKitView) does not exist.
2012-11-05 14:21:30.895 sawdaysApp[25398:c07] ERROR: Plugin 'MapKitView' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist.
2012-11-05 14:21:30.896 sawdaysApp[25398:c07] FAILED pluginJSON = [null,"MapKitView","showMap",[]]
2012-11-05 14:21:30.896 sawdaysApp[25398:c07] CDVPlugin class MapKitView (pluginName: MapKitView) does not exist.
2012-11-05 14:21:30.896 sawdaysApp[25398:c07] ERROR: Plugin 'MapKitView' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist.
2012-11-05 14:21:30.897 sawdaysApp[25398:c07] FAILED pluginJSON = [null,"MapKitView","setMapData",[{"diameter":1000,"offsetTop":25,"lon":-123.104446,"buttonCallback":"cbMapCallback","lat":49.281467999999997,"height":360,"atBottom":true}]]
我认为错误与CDVPluggin中的MapKitView有关,但实际上并不确定。
有没有人有过这方面的经验并成功了?
答案 0 :(得分:1)
这项工作。最后:)
1 - 按照本指南启动应用http://docs.phonegap.com/en/2.1.0/guide_getting-started_ios_index.md.html
2 - 在插件文件夹和www文件夹中的.js文件中下载并添加mapkit插件本机文件(所有这些文件)。 https://github.com/phonegap/phonegap-plugins/tree/master/iOS/MapKit。 确保将pluggins文件夹拖放到xcode中的pluggins文件夹,否则应用程序将无法正确链接文件。
3 - 白名单*将所有域列入白名单并在Cordova.plist MapKitView上添加插件引用作为值和键
4 - 已加载并包含在sawdaysTestApp / pluggins文件夹中JSONKit.h和JSONKit.m https://github.com/johnezang/JSONKit
5 - 更改mapkit.h和.m
#ifdef CORDOVA_FRAMEWORK
#import <Cordova/CDVPlugin.h>
#else
#import "CDVPlugin.h"
#endif
to
#import <Cordova/CDVPlugin.h>
和
更改mapkit.m
from
#ifdef CORDOVA_FRAMEWORK
// PhoneGap >= 1.2.0
#import <Cordova/JSONKit.h>
#else
// https://github.com/johnezang/JSONKit
#import "JSONKit.h"
#endif
to
#import "JSONKit.h"
7 - 更改index.html
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" charset="utf-8" src="MapKitPlug.js"></script>
要//
<script type="text/javascript" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8" src="MapKit.js"></script>
8 - 运行模拟器。单击“显示地图”按钮。
答案 1 :(得分:0)
我想添加两件事:
1,截至Cordova 2.3.0文件名
Cordova.plist
现在是
yourProject-Info.plist
yourProject 就是你的项目名称。
2,我发现你仍然需要将二进制文件链接到图书馆&#39;通过执行以下操作: