糖果派对官方网站_可以赌钱的糖果游戏_手机版
bb电子糖果派对高德地图,实时获取中央点的经纬度和地点

bb电子糖果派对高德地图,实时获取中央点的经纬度和地点

作者:网络编程    来源:未知    发布时间:2020-04-26 20:10    浏览量:

近来品种须求选择高德地图,一贯在捣鼓,当中二个急需是:要求公司客商,能够在地图上采用本身的合作社地点,然后把那个岗位记录下来传给服务器.

1.在Pods中导入AMap2DMap,AMapFoundation,AMaplocation,AMapSearch,PKHUD工具
2.开立四个OC桥接文件,导入:

首回用,各类踩坑,问来问去,决定仍然友好切磋,幸亏,搞出来了,方法分享如下:

import <AMapSearchKit/AMapSearchKit.h>

思路有三种:

import <MAMapKit/MAMapKit.h>

1.大头针不动,让客户移动地图,然后实时获取大头针所在地点的中纬度新闻.

import <AMapFoundationKit/AMapFoundationKit.h>

2.稳住地图,移动大头针,然后取到大头针落点的地点.

import <MAMapKit/MAMapView.h>

笔者用的首先种格局,感到温馨操作一点:

import <AMapLocationKit/AMapLocationKit.h>

率先:在地形图中央放三个UIImageView,增加多个大头针的图片作者用的是系统自带的图纸(redPin.png卡塔尔,这里有个坑,系统自带的大头针图片都放在AMap.bundle里面,不过大家在下载SDK的时候,貌似不会下载这些,作者也是看了法定demo,才找到那个AMap.bundle.所以,(关于demo,必必要多看,特别是没思路的时候,挺有利于的卡塔尔(قطر‎.

import <Foundation/Foundation.h>

下一场:从demo中抽取AMap.bundle,拖进本人的花色,就能够.注意:这里又有一个坑,导入现在,点开看会发觉,文件夹是中绿的,小编先是次给加上海教室片,直接就imageView.image = [UIImage imageNamed:@"redPin"]bb电子糖果派对,;然而,运行开掘,图片并从未突显.全体,须求大家手动把redPin.png和2x,3x的图形拖到AMap.bundle外面包车型客车目录,那样,图片就展现出来了.

import <AMapSearchKit/AMapSearchAPI.h>

3.在OneMapViewController界面中世襲
MAMapViewDelegate,AMapSearchDelegate,AMapLocationManagerDelegate,UIGestureRecognizerDelegate并关联

概念全局变量:
var mapView:MAMapView?
var search:AMapSearchAPI!
var searchButton:UIButton!
//七个岗位,三个永世,叁个动,总括间隔
var coordinatePoint:MAMapPoint! //坐标(随意自个儿点的职务State of Qatar
var locationPoint:MAMapPoint! //地点(固定地方卡塔尔国

5.增加一七种函数:
1State of Qatar初步化地图:

func initMapView(){
    let compassX = mapView?.compassOrigin.x
    let scaleX = mapView?.scaleOrigin.x

    //设置指南针和比例尺的位置
    mapView?.compassOrigin = CGPointMake(compassX!,21)
    mapView?.scaleOrigin = CGPointMake(scaleX!,21)
    mapView = MAMapView(frame:self.view.bounds)
    mapView?.delegate = self

// self.view.addSubview(mapView!)
// self.view.sendSubviewToBack(mapView!)
// mapView!.mapType = .Satellite
mapView!.showsUserLocation = true//开启定位
self.view.addSubview(mapView!)
self.view.sendSubviewToBack(mapView!)
//设置客户是还是不是自定义范围circle
// mapView?.customizeUserLocationAccuracyCircleRepresentation = true
// mapView!.userTrackingMode = MAUserTrackingModeFollow
// mapView?.allowsBackgroundLocationUpdates = true
mapView?.userTrackingMode = .Follow
mapView!.distanceFilter = 500.0
mapView!.desiredAccuracy=kCLLocationAccuracyBestForNavigation
}
2).
累积大头针:
func mapView(mapView: MAMapView, viewForAnnotation annotation: MAAnnotation) -> MAAnnotationView? {

    if annotation.isKindOfClass(MAPointAnnotation) {
        let annotationIdentifier = "invertGeoIdentifier"
        var poiAnnotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(annotationIdentifier) as? MAPinAnnotationView

        if poiAnnotationView == nil {
            poiAnnotationView = MAPinAnnotationView(annotation: annotation, reuseIdentifier: annotationIdentifier)
        }
        //设置动画显示,默认为NO
        poiAnnotationView!.animatesDrop   = true
        //设置气泡可以弹出,默认为NO
        poiAnnotationView!.canShowCallout = true
        //设置大头针颜色
        poiAnnotationView?.pinColor = MAPinAnnotationColor.Purple
        poiAnnotationView?.image = UIImage(named: "sport-car.png")
        //            poiAnnotationView!.canShowCallout = true    //设置气泡可以弹出,默认为NO
        //            poiAnnotationView!.animatesDrop = true    //设置标注动画显示,默认为NO
        //           poiAnnotationView!.draggable = true   //设置标注可以拖动,默认为NO
        //            poiAnnotationView!.pinColor = MAPinAnnotationColor.Green
        return poiAnnotationView
    }
    return nil
}

3).
//逆地理编码回调
func onReGeocodeSearchDone(request: AMapReGeocodeSearchRequest, response: AMapReGeocodeSearchResponse) {
if (response.regeocode != nil) {
let coordinate = CLLocationCoordinate2DMake(Double(request.location.latitude), Double(request.location.longitude))
let annotation = MAPointAnnotation()
annotation.coordinate = coordinate
annotation.title = response.regeocode.formattedAddress
annotation.subtitle = response.regeocode.addressComponent.province
print(annotation.titleState of Qatar //获取地方具体音信
mapView!.addAnnotation(annotation)
let overlay = MACircle(centerCoordinate: coordinate, radius: 40.0卡塔尔(قطر‎//加多大头针的半径
mapView!.addOverlay(overlay)
}
}
//逆地理编码乞请
func oppositeGeoCodeRequeset(coor: CLLocationCoordinate2D){
let searchRequest = AMapReGeocodeSearchRequest()
searchRequest.location = AMapGeoPoint.locationWithLatitude(CGFloat(coor.latitude), longitude: CGFloat(coor.longitude))
self.search.AMapReGoecodeSearch(searchRequest)
}

4.别的增多
reloadMap,initSearch,initGestureRecognizer,searchReGeocodeWithCoordinate, gestureRecognizer,handleLongPress,mapView(mapView: MAMapView , didUpdateUserLocation userLocation: MAUserLocation ) ,twoPointDistance,dangerousWarn,
mapView(mapView: MAMapView, rendererForOverlay overlay: MAOverlay) -> MAOverlayRenderer?函数,intAddWarn

终极,正是导入相关的SDK(此处用的2D地图SDKState of Qatar,调用代理方法了,

在viewController.m 导入:

下一篇:没有了
友情链接: 网站地图
Copyright © 2015-2019 http://www.tk-web.com. bb电子糖果派对有限公司 版权所有