cocoaPods结合高德地图使用自动部署

高德官方自动部署(只有简单的使用)http://lbs.amap.com/api/ios-sdk/guide/deploy/

开题“

注意:::下载什么类库需要$ pod search AFNetworking(类库名字)!!

 

偷懒:复制下面创建一个脚本直接进行安装。或者复制到命令行粘贴。 

sudo gem install cocoapods
gem sources --remove https://rubygems.org/

echo '更改代理,有可能出错,如果出错暴力更改即可'
gem sources -a http://ruby.taobao.org/

gem sources -l
sudo gem install cocoapods

 

cocoaPods

 

一、cocoaPods简介

类库管理工具。主要用途就是更新项目中的类库比较方便。

二、安装

前置环境Ruby环境:

Ruby:一种脚本语言,特点是简单快捷并面向对象。objective-c就是一种典型的简单的面相对象语言。

Ruby安装:

 

Madordie:~ KTJ$ gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources
Madordie:~KTJ $ gem sources -a https://ruby.taobao.org/
https://ruby.taobao.org/ added to sources Madordie:~ KTJ$ gem sources -l *** CURRENT SOURCES *** https://ruby.taobao.org/ 

cocoaPods安装:

Madordie:~ KTJ$ sudo gem install cocoapods
WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.
To proceed, enter your password, or type Ctrl-C to abort.
Password:
Fetching: i18n-0.6.11.gem (100%)

此处省略两千行。。。 

        Madordie:~ KTJ$

 

 

三、使用

$ pod search AFNetworking 在cocoaPods中搜索AFNetworking库。如果支持则打印库的相关信息。

组织更新规则,有点类似Makefile。。

命令进入项目目录。

 

--------以下操作都是基于高德地图的使用。----------------

 

注意:下面这条命令用来解决pod install 时候xcrun: error: active developer path ("/Volumes/Xcode/Xcode.app/Contents/Developer") does not exist, use xcode-select to change

 

Madordie:firstaMap KTJ$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Password:
Madordie:firstaMap KTJ$
Madordie:keith1408 KTJ$ cd amap-自动部署3D/
Madordie:amap-自动部署3D KTJ$ ls
Podfile amap-自动部署3D.xcodeproj
amap-自动部署3D amap-自动部署3DTests
Madordie:amap-自动部署3D KTJ$ vim Podfile
Madordie:amap-自动部署3D KTJ$ pod install
Analyzing dependencies
CocoaPods 0.35.0.rc1 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
[!] Unable to find a specification for `AMap333DMap` depended upon by Podfile.
Madordie:amap-自动部署3D KTJ$ vim Podfile
Madordie:amap-自动部署 KTJ$ ls
JGShowMapViewController.h amap-自动部署
JGShowMapViewController.m amap-自动部署.xcodeproj
Podfile amap-自动部署.xcworkspace
Podfile.lock amap-自动部署Tests
Pods
Madordie:amap-自动部署 KTJ$ cat Podfile
platform :ios, '7.0'
pod 'AMap2DMap'
pod 'AMapSearch'
Madordie:amap-自动部署 KTJ$ cat ../amap-自动部署3D/Podfile
platform :ios, '7.0'
pod 'AMap3DMap'
pod 'AMapSearch'

Madordie:amap-自动部署 KTJ$
Madordie:amap-自动部署3D KTJ$ pod install
Analyzing dependencies
CocoaPods 0.35.0.rc1 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Downloading dependencies
Installing AMap3DMap (2.4.0)
Installing AMapSearch (2.4.0)
Generating Pods project
Integrating client project
[!] From now on use `amap-自动部署3D.xcworkspace`.
[!] The use of implicit sources has been deprecated. To continue using all of the sources currently on your machine, add the following to the top of your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
Madordie:amap-自动部署3D KTJ$
四、更新类库
Madordie:amap-自动部署3D KTJ$ pod update
Update all pods
Analyzing dependencies
CocoaPods 0.35.0.rc1 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.
For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.
Downloading dependencies
Using AMap3DMap (2.4.0)
Using AMapSearch (2.4.0)
Generating Pods project
Integrating client project
[!] The use of implicit sources has been deprecated. To continue using all of the sources currently on your machine, add the following to the top of your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
Madordie:amap-自动部署3D KTJ$ 

 

总结:

该类库功能确实强大,并且一次搭建,永久使用。一行代码搞定类库更新添加神马的。提高开发xiaol!

 

总结一下大致步骤:

搭建ruby环境。

安装cocoaPods

根据需求编写Podfile (该步骤比较重要)

安装类库

根据需求更新类库

 

不要害怕错误,看错误日志,基本上学过英语的都OK

转载于:https://www.cnblogs.com/madordie/p/4072884.html

在Vue.js中结合高德地图来规划出行路线,可以分为以下几步操作: 1. 引入依赖:安装`@vue-amap/core`和`@vue-amap/router-plugin`库,这两个是基于Vue的AMAP官方组件包,可以在项目中通过npm或yarn安装。 ```bash npm install @vue-amap/core @vue-amap/router-plugin ``` 2. 配置AMAP:在main.js或Vuex中初始化高德地图,提供key和默认中心点。 ```javascript import AMap from '@vue-amap/core' AMap.initAMapApiLoader({ key: 'your_amap_key', // 在高德官网申请的地图API Key v: '1.4.17' // 使用高德地图版本 }); ``` 3. 创建地图组件:创建一个新的Vue组件,例如`MapView.vue`,然后引入AMap组件和对应的插件。 ```html <template> <div ref="map" :style="{width: '100%', height: '100%'}"></div> </template> <script> import { Map } from '@vue-amap/core' import Router from '@vue-amap/router-plugin' export default { components: { Map }, mounted() { const map = new Map(this.$refs.map, { zoom: 8, center: [116.39, 39.9] }) // 设置地图初始位置 this.$router.use(Router, map) // 初始化路由管理器 } } </script> ``` 4. 路线规划功能:在需要规划路径的地方,使用`amap.services.route.calculateRoute()`函数。这通常在点击“开始导航”按钮触发的事件处理器里实现。 ```javascript methods: { planRoute(start, end) { if (!start || !end) return AMap.plugin('AMap.services', () => { let router = new AMap.Routing(); router.calculate( start, // 起始地点坐标 end, // 终点地点坐标 { // 参数配置 prefer: 'driving', // 行驶模式选择 resultType: 'all' // 返回结果类型 }, res => { console.log(res) // 根据返回结果显示或保存路径 }, err => { console.error(err) } ); }); } } ``` 5. UI交互:在UI设计上添加起点和终点输入框,以及“开始导航”按钮,当用户输入地址并点击时,触发`planRoute`方法。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值