1. 程式人生 > >swift地圖定位(十九)整合百度地圖

swift地圖定位(十九)整合百度地圖

ViewController.swift

//
//  ViewController.swift
//  baidumapfirsttest
//
//  Created by targetcloud on 2016/11/16.
//  Copyright © 2016年 targetcloud. All rights reserved.

//準備:
//下載包
//http://wiki.lbsyun.baidu.com/cms/iossdk/sdk/BaiduMap_IOSSDK_v3.1.0_All.zip
//生成金鑰(API控制檯) http://lbsyun.baidu.com/apiconsole/key
//wRRSuxGeEiD1yiPv8ej4XucCnTbjtQfR

//開始整合
//1 add ATS

//2 拖包
//BaiduMapAPI_Base.framework
//BaiduMapAPI_Cloud.framework
//BaiduMapAPI_Location.framework
//BaiduMapAPI_Map.framework
//BaiduMapAPI_Radar.framework
//BaiduMapAPI_Search.framework
//BaiduMapAPI_Utils.framework

//3 新增系統庫的依賴在Linked Frameworks and Libraries
//CoreLocation.framework
//QuartzCore.framework
//OpenGLES.framework
//SystemConfiguration.framework
//CoreGraphics.framework
//Security.framework
//libsqlite3.0.tbd
//CoreTelephony.framework
//libstdc++.6.0.9.tbd

//4 在Build Settings 查詢框中輸入other link,然後在找到下面列表中的 Other Linker Flags 中輸入-ObjC

//5 拖入BaiduMapAPI_Map.framework-> Resources-> mapapi.bundle 到工程中

//6 建立橋接檔案(OC 到 swift), 在BMKSwiftDemo-Bridging-Header.h中輸入
//#import <BaiduMapAPI_Base/BMKBaseComponent.h>//引入base相關所有的標頭檔案
//#import <BaiduMapAPI_Map/BMKMapComponent.h>//引入地圖功能所有的標頭檔案
//#import <BaiduMapAPI_Search/BMKSearchComponent.h>//引入檢索功能所有的標頭檔案
//#import <BaiduMapAPI_Cloud/BMKCloudSearchComponent.h>//引入雲檢索功能所有的標頭檔案
//#import <BaiduMapAPI_Location/BMKLocationComponent.h>//引入定位功能所有的標頭檔案
//#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>//引入計算工具所有的標頭檔案
//#import <BaiduMapAPI_Radar/BMKRadarComponent.h>//引入周邊雷達功能所有的標頭檔案
//#import <BaiduMapAPI_Map/BMKMapView.h>//只引入所需的單個頭檔案

//7配置橋接檔案
//在 Build Setting 查詢框中輸入brid,在下面的列表中找到Objective-C Bridging Header 中輸入baidumapfirsttest/BMKSwiftDemo-Bridging-Header.h

//8 info.plist 新增Bundle display name

//9 新增程式碼

import UIKit

class ViewController: UIViewController {

    var _mapView: BMKMapView?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        _mapView = BMKMapView(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height))
        self.view.addSubview(_mapView!)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        _mapView?.viewWillAppear()
//        _mapView?.delegate = self // 此處記得不用的時候需要置nil,否則影響記憶體的釋放
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        _mapView?.viewWillDisappear()
        _mapView?.delegate = nil // 不用時,置nil
    }
}

AppDelegate.swift
//
//  AppDelegate.swift
//  baidumapfirsttest
//
//  Created by targetcloud on 2016/11/16.
//  Copyright © 2016年 targetcloud. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var _mapManager: BMKMapManager?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        _mapManager = BMKMapManager()
        // 如果要關注網路及授權驗證事件,請設定generalDelegate引數
        let ret = _mapManager?.start("wRRSuxGeEiD1yiPv8ej4XucCnTbjtQfR", generalDelegate: nil)
        if ret == false {
            NSLog("manager start failed!")
        }
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}


相關推薦

swift地圖定位整合地圖

ViewController.swift // // ViewController.swift // baidumapfirsttest // // Created by targetcloud on 2016/11/16. // Copyright © 2016年

Spring.NET教程整合NHibernate和ASP.NET MVC(基礎篇)

contains sar occurs false port company param soft stat 今天帶給大家的就是期待以久的ASP.net MVC與Spring.NET和NHibernate的組合,視圖打造.NET版的SSH(Spring-Struts-Hib

Spring Boot入門系列整合mybatis,使用註解實現動態Sql、引數傳遞等常用操作!

前面介紹了Spring Boot 整合mybatis 使用註解的方式實現資料庫操作,介紹瞭如何自動生成註解版的mapper 和pojo類。 接下來介紹使用mybatis 常用註解以及如何傳引數等資料庫操作中的常用操作。 其實,mybatis 註解方式 和 XML配置方式兩者的使用基本上相同,只有在構建 SQL

AngularJS進階()在AngularJS應用中整合地圖實現定位功能

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

ios 整合地圖獲取定位,反向地理編碼

原因 :之所以使用百度地圖,是因為當時使用蘋果自帶的定位給後臺傳經緯度,後臺用百度解析誤差比較大,所以換成了百度地圖 本文主要講解下cocoapods 整合 看詳細整合請點選(cocoapod整合連結) 1 、首先去百度地圖開放平臺註冊賬戶 點選立即使用 然後註冊 2、然後進行郵箱啟用

聊聊高並發理解並發編程的幾種&quot;性&quot; -- 可見性,有序性,原子性

sock clas 關註 條件 infoq zed 應該 單獨 ssa 這篇的主題本應該放在最初的幾篇。討論的是並發編程最基礎的幾個核心概念。可是這幾個概念又牽扯到非常多的實際技術。比方Java內存模型。各種鎖的實現,volatile的實現。原子變量等等,每個都可以展開

安裝命令

配置文件 軟件包 import 認證 安裝命令:yum,rpm19.1.rpm功能:rpm軟件包管理器常用選項:-ivh 安裝軟件包-Uvh 升級軟件包,如果原來軟件包不存在則安裝-Fvh 升級軟件包,如果原來的軟件包不存在則停止升級-e 卸載軟件包--nodeps 忽略依

selenium測試Java--截圖

int tput apache [] catch take screens umt ott package com.test.screenshot; import java.io.File; import java.io.IOException; import org

Python學習筆記

插入 imp 集合類 屬性 counter 以及 雙向 ror 簡單的 一、collections介紹   collections是Python中內建的一個集合模塊,提供了許多有用的集合類 二、namedtuple   namedtuple是一個函數,用來創建一個類似類的自

Linux系列教程——Linux文件系統管理之手工分區

image u盤 true 掛載 但是 常用 選項 光盤 幫助   上篇博客我們首先介紹了硬盤為什麽要分區,以及Linux系統的幾種分區類型,然後介紹了Linux系統幾個常用的文件系統命令,最後講解了掛載命令,並通過實例演示了如何掛載光盤和U盤。   本篇博客我們將介紹l

Linux命令 查看系統負載 uptime

time 長時間 連接 時間間隔 過大 post 依次 查看 local 一、命令介紹 Linux 系統中 uptime 命令主要用於獲取主機運行時長和查詢Linux系統負載等信息。 uptime 命令可以顯示系統已經運行了多長時間,信息顯示依次為:現在時間、系統已經運行時

JmeterLogic Controller 之 Module Controller and Include Controller

log and sampler control gpo nbsp jmx pos 開始 Module Controller ---模塊控制器   測試計劃設置“獨立運行沒每個線程組”     線程組2中使用Module Controller執行線程組1中的Sampler:

ShaderLab學習小結RenderToCubemap創建能反射周圍環境的效果

隨著 思路 edi 繼續 size material cubemap 緩沖區 方法 繼續用“ShaderLab學習小結(十八)cubemap”中所做的shader想要讓它能對周圍的環境進行反射思路就是要讓它的cubemap裏的內容是周圍環境的映射shader不變,就要想辦法

python學習筆記面向對象編程,類

時代 alt 類名 rst tps 玉溪 connect nbsp nco 一、面向對象編程 面向對象,是一種程序設計思想。 編程範式:編程範式就是你按照什麽方式去編程,去實現一個功能。不同的編程範式本質上代表對各種類型的任務采取的不同的解決問題的思路,兩種最重要的編程範式

Spring Boot教程整合elk1

分享圖片 operation you 運行 hot href iba for 分享 elk 簡介 Elasticsearch是個開源分布式搜索引擎,它的特點有:分布式,零配置,自動發現,索引自動分片,索引副本機制,restful風格接口,多數據源,自動搜索負載等。

Linux學習筆記文件壓縮

文件壓縮一、常見的壓縮文件 Windows .rar .zip .7z Linux .zip,.gz,.bz2,.xz,.tar.gz,.tar.bz2,.tar.xz文件壓縮可以節省內存,也可以節省傳輸速度 二、gzip首先創建了一個文件夾 /tmp/d6z/找了些比較大的文件寫入1.txt例如find

Linux 學習總結正則三劍客之grep

grepgrep 過濾器,egrep可以理解為grep的升級版1 格式:grep [-cinvABC] ‘word‘ filename-c:統計符合要求的行數例如 : grep -c ‘root‘ /etc/passwdgrep -c ‘‘ /etc/passwd 統計文件總行數-i:忽略大小寫-n:行號輸出

Hadoop學習之路MapReduce框架排序

ati ioe extends 一個用戶 必須 idt 構造 sta gpo 流量統計項目案例 樣本示例 需求 1、 統計每一個用戶(手機號)所耗費的總上行流量、總下行流量,總流量 2、 得出上題結果的基礎之上再加一個需求:將統計結果按照總流量倒序排序 3

QT之布局管理器

QT 布局管理器 水平 垂直 我們在之前的 GUI 開發中都是使用的是絕對定位,何謂絕對定位呢?就是我們直接在像素級指定各個組件的位置和大小。比如我們之前使用的 void QWidget::move(int x, int y);void QWidget::resize(int

C之宏定義

C語言 宏定義 #define 我們在 C 語言中經常會用到宏定義,那麽我們今天就對宏做個簡單的介紹。#define 是預處理期處理的單元實體之一;它定義的宏可以出現在程序的任意位置;它定義之後的代碼都可以使用這個宏。 #define 定義的宏常量可以直接使用,其本質