Integrated Google Maps encountered in those pits and solutions

Source: Internet
Author: User
Tags sin
Integrated Google Maps encounter those pits and solutions that were written in the spring of 2017

Preface W even le a go to csdn since also have markdown sketch way, I know today, comfort oneself: Any after knowing, look back, feel is also Meng Meng

What are the pits?

1. Download SDK time is too long
In the civil service network from GitHub on the pod ' GoogleMaps ', OK, it is so simple, hundreds of trillion googlemaps module, this process in the domestic need to spend a long time, you can go to play a basketball and then come back to see if there is a good download
2. Chinese website SDK use method update not timely
Wipe, this place if not familiar with the time is time-consuming ah, at least take you half a day to integrate. The website explains pod ' GoogleMaps ' from GitHub, in fact, when you use it, you will find that there are fewer classes.

3. Position offset
Celestial, we. You're not used to it, it doesn't matter, you get used to it.

Solutions

1. Download SDK time is too long
Dude, I downloaded it. You can ask me, hahaha, I'm so ready to help.
2. Chinese website SDK usage update not in time
Said the truth of Google, the thought of their own quality so high, or endure, <-_<-.
In fact, Google Map SDK in the 2.1.1 of the SDK module, but also need to import googleplaces module, in the address selector when found a Placepicker class, look for, did not find any shadow, do I download the SDK again problem. No, do not doubt yourself, not to doubt life, but often we can not help but doubt. In fact, the Google Map SDK is completely modular and will placepicker a single module. Paste code:
Source ' https://github.com/CocoaPods/Specs.git '
Platform:ios, ' 8.1 '
pod ' googlemaps '
pod ' GOOGL Eplaces ', ' ~> 2.1.1 '
pod ' googleplacepicker ', ' ~> 2.1.1 '
3. Position offset
Google Map SDK display bit in China There are deviations, specific reasons why there is a deviation I do not elaborate, in fact, even I do not understand why to set this road without meaning. Thousand find million besides is found a solution. Found a section of Java code, modified to the OBJECTIVE-C code I need, since then I big OC sector do not go to ask, by the pro-test, in. , Paste code:

@interface Correntlocationtool:nsobject + (cllocationcoordinate2d) Correntlocation: (cllocationcoordinate2d) Cor;
@end #import "CorrentLocationTool.h" @implementation correntlocationtool static double pi = 3.14159265358979324;
static Double A = 6378245.0;

static double ee = 0.00669342162296594323;
    + (Cllocationcoordinate2d) Correntlocation: (cllocationcoordinate2d) Cor {double Wglat = cor.latitude;
    Double Wglon = cor.longitude;

    cllocationcoordinate2d coordinate;
        if (Outofchina (Wglat, Wglon)) {coordinate.latitude = Wglat;
        Coordinate.longitude = Wglon;
    return coordinate;
    Double Dlat = Transformlat (wgLon-105.0, wgLat-35.0);

    Double Dlon = Transformlon (wgLon-105.0, wgLat-35.0);
    Double Radlat = wglat/180.0 * PI;
    Double magic = sin (Radlat);
    Magic = 1-ee * Magic * MAGIC;

    Double sqrtmagic = sqrt (Magic);
    Dlat = (Dlat * 180.0)/((A * (1-ee))/(Magic * sqrtmagic) * pi); Dlon = (Dlon * 180.0)/(A/Sqrtmagic * COS (radlat) * pi);
    Coordinate.latitude = Wglat + Dlat;

    Coordinate.longitude = Wglon + Dlon;
return coordinate;
    static bool Outofchina (double lat, double lon) {if (Lon < 72.004 | | lon > 137.8347) return true;
    if (Lat < 0.8293 | | | lat > 55.8271) return true;
return false; Static double Transformlat (double x, double y) {double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x *
    Y + 0.2 * sqrt (fabs (x));
    RET = = (20.0 * SIN (6.0 * x * pi) + 20.0 * SIN (2.0 * x * pi)) * 2.0/3.0;
    RET = = (20.0 * sin (y * pi) + 40.0 * sin (y/3.0 * pi)) * 2.0/3.0;
    ret = = (160.0 * sin (y/12.0 * pi) + pi/30.0 (y *)) * 2.0/3.0;
return ret;  Static double Transformlon (double x, double y) {double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
    * SQRT (fabs (x));
    RET = = (20.0 * SIN (6.0 * x * pi) + 20.0 * SIN (2.0 * x * pi)) * 2.0/3.0; RET = = (20.0 * sin (x * pi) + 40.0 * sin (X/3).0 * pi)) * 2.0/3.0;
    ret = = (150.0 * sin (x/12.0 * pi) + 300.0 * sin (x/30.0 * pi)) * 2.0/3.0;
return ret; } @end
Attention matters
(1) Integrated 2.1.1 version of the GoogleMaps SDK if you need an address, you need to register two services
    [Gmsservices provideapikey:@ "Yours Key"];
    [Gmsplacesclient provideapikey:@ "Yours Key"];
(2) The domestic visit by the wall, is currently preparing to deal with this issue, handled well, on Weibo told everyone

PS: The first use of markdown on the network to write articles, the format is not very good, make up to see

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.