Baidu maps iOS development experience sharing

Source: Internet
Author: User

Recently completed the app in the application of the map, feeling very tortuous, tossing a long time, just beginning has been unable to successfully use the Baidu Map API, reported a lot of errors, later changed to the high-D map, and found that the service side of the use of Baidu's latitude and longitude, and from high-back Baidu, tears ran.

Here a simple comparison of the high-German map and Baidu map, the personal feel that the introduction of the German map API is very simple, but also divided into several versions, compared to Baidu Map API import is more cumbersome, mainly import static library files, the first use is really cumbersome, Baidu provides three ways to import, Finally, it is convenient to merge the static library files, or to make many settings in Xcode, but also to change according to various circumstances, so I suggest or choose the second way.

Baidu Map API, it is best to go to the official Technology forum download two PDF files: iOS Development tutorial-the first part and the second part of the PDF file, these two files are too useful, do not go to the demo, do not go to search tutorials, with this two files is enough, nothing to do not go to the forum to ask questions, It's hard to get a response, it's a bunch of official responses, almost useless.

iOS development tutorial-Part one. pdf is mainly about how to apply key, and how to import the API into the Xcode project. Be sure to follow the instructions in the PDF, otherwise there are a lot of questions. When importing a static library, it is best to choose the second method, which is relatively simple to maintain. Some configurations (such as libary search paths and header search paths) are set up for you when you import, so you don't have to consider

If the import process is perfect, behind the development is very simple things, Baidu API introduction is also relatively complete, use it very handy.

iOS development tutorial-Part two. pdf is mainly on the Baidu map function of the various introduction, this you will not get all the available things, you need to combine the demo together, first from the PDF to find the function you need, there is a general understanding, then to see the code in the demo, and then the actual application to your project.

List a few problems encountered

1. Baidu read the cllocationcoordinate2d problem, Latest Version (V2.5) cllocationcoordinate2dmake Two parameters contrary to the previous function, this troubled me for a long time, the previous version and the current version of the program, with the same latitude and longitude, the old version can display the label, the new version of the But can not.

Example: The old version is like this

[Self.mapview Setcentercoordinate:cllocationcoordinate2dmake (118.144992,24.497386)];

That's the new version.

[Self.mapview Setcentercoordinate:cllocationcoordinate2dmake (24.497386,118.144992)];

Do not know why Baidu to do this

Method of 2.BMKMapViewDelegate

-(void) Mapview: (Bmkmapview *) Mapview Didselectannotationview: (Bmkannotationview *) view

This will only be done once after clicking on the same label, and clicking on the other annotations will then be executed.

It was later found that the [Mapview deselectAnnotation:view.annotation Animated:yes] could be called at each execution time;

This same annotation can be executed consistently, do not ask why I need this function, because I have to hide the bubble, only by clicking on the callout to achieve.

3. Calculate the labeling method in the screen, here directly on the code, the experiment is available

First, convert the latitude and longitude to the in-screen coordinates

Cgpoint point = [Self.mapview convertCoordinate:annotationitem.coordinate ToPointToView:self.mapView];

Then determine if the coordinates are within the visible range of the map

Cgrectcontainspoint (CGRectMake (0, Self.mapView.frame.size.width, self.mapview.frame.size.height-44-49), point)

Method of 4.BMKMapViewDelegate

-(Bmkannotationview *) Mapview: (Bmkmapview *) View viewforannotation: (id<bmkannotation>) annotation

When you use this method, you may use a custom Bmkannotationview class, but when you call a custom class Bmkannotationview, invoke the newly defined method or property, first execute the

annotationview.annotation = annotation;

Make sure you're in front of the other code you want to execute.

--------------------------------------------------------------------------------------------------------------- ----------------

Because the actual and did not use the Baidu map too many complex functions, so can only be summed up here ....

Baidu maps iOS development experience sharing

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.