iOS about Baidu map coordinate offset processing

Source: Internet
Author: User

iOS about Baidu map coordinate offset processing

Define a macro to convert

#define Cbcoorconvert (coor) bmkcoordictionarydecode (BMKBAIDUCOORFORGCJ (coor))

Use

-(ID) Initwithjson: (Nsdictionary *) json{    if (self = [Super Initwithjson:json]) {         = [json objectforkey:@ "newmileage"];                Cllocationcoordinate2d coor;         = [self Getlat];         = [self Getlon];         = Cbcoorconvert (coor);    }     return Self ;}

Baidu API Introduction:

/** coordinate conversion function, from the original GPS coordinates, Mapbar coordinates converted to Baidu coordinates * @param coorWgs84 to be converted to the original GPS coordinates, or mapbar coordinates * @return The returned nsdictionry contains "x", "Y" field , each corresponding to the x, Y coordinates after Base64 encryption*/Uikit_extern nsdictionary*BMKBaiduCoorForWgs84 (cllocationcoordinate2d coorWgs84);/** coordinate conversion function, from Google coordinates, 51 map coordinates, MAPABC coordinates to Baidu coordinates (51 map coordinates need to show 10000) * @param coorgcj to convert Google coordinates, 51 map coordinates, MAPABC coordinates *@ Return nsdictionry contains "x", "Y" fields, each corresponding to the x, Y coordinates after Base64 encryption*/Uikit_extern nsdictionary*BMKBAIDUCOORFORGCJ (cllocationcoordinate2d coorgcj);/** *base64 Encrypted coordinate dictionary decryption function * @param dictionary with decrypted Nsdictionry, the nsdictionry should contain "x", "Y" field, each corresponding to Base64 encryption after the x, y coordinates *@ The coordinates after return decryption*/uikit_extern cllocationcoordinate2d bmkcoordictionarydecode (nsdictionary* dictionary);

Baidu positioning SDK can return three kinds of coordinate system,

respectively:

Bd09( Baidu Mercator coordinate system),

Bd09ll( Baidu latitude and longitude coordinate system),

Gcj02( By default , the latitude coordinate system of the National Geodetic Bureau),

Among them, bd09ll can be displayed without bias on the Baidu map.

Conversion is connected to the service of Baidu, not local conversion,

reference:http://qiansheep.blog.163.com/blog/static/3506872020139171153881/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.