I have recently developed a map software program to write some experiences and experiences, as well as some problems.
Management reminder:This post is set as excellent by gagaga)
The source code of this software is here:
Http://www.cocoachina.com/bbs/read.php? Tid = 19117
1. Many people ask how to calculate the distance between two points, which is actually very simple.
Prepare two cllocation objects, for example, to calculate a location andUseThe distance from the current location. One of the cllocations is userlocation = [locationmanager location], and the locationmanager is the instance of cllocationmanager. The [locationmanager startupdatinglocation] has been executed.
Then calculate the distance between the two cllocations (formatted12.34 km):
Copy code
- [Nsstring stringwithformat: @ "% 0.2f km", [userlocation getdistancefrom: location]/1000]
|
2. When processing the mkannotationview, you must determine whether the corresponding annotation is mkuserlocation, the blue point that shows the user's current location, to avoid misoperation.
Copy code
- [Annotation iskindofclass: [mkuserlocation class]
|
3,-(mkannotationview *) mapview :( mkmapview *) mapview viewforannotation :( id <mkannotation>) Annotation
This delegate function is generally executed immediately after annotations are added to the mkmapview object, but the execution will not end immediately. If you call
[Mapview viewforannotation: someannotation]; The nil result will be returned, and any operations on the returned nil will not be performed inScreenShow ......
4. When the mkmapview is zoomed in and out, you must note that the mkmapview is zoomed in at least two times.
| copy the Code
- -(ibaction) dozoomin :( ID) sender {// zoom in
- mkcoordinateregion region = mmapview. region;
- region. span. latitudedelta = region. span. latitudedelta * 0.4;
- region. span. longitudedelta = region. span. longitudedelta * 0.4;
- [mapview setregion: Region animated: Yes];
- }
- -(ibaction) dozoomout :( ID) sender {// zoom out
- mkcoordinateregion region = mmapview. region;
- region. span. latitudedelta = region. span. latitudedelta * 1.3;
- region. span. longitudedelta = region. span. longitudedelta * 1.3;
- [mapview setregion: Region animated: Yes];
- }
|
5. Below are some otherCodeFor Search Engines
Copy code
- Cllocationcoordinate2d coordinate;
- // Location Paris
- Coordinate. Longitude = 48.856660;
- Coordinate. longpolling = 2.350996;
- Mkcoordinateregion viewregion = mkcoordinateregionmakewithdistance (coordinate, distance, distance );
- Mkcoordinateregion adjustedregion = [mapview regionthatfits: viewregion];
- [Mapview setregion: adjustedregion animated: animated];
|
6. Problem:
A bug was found in the callout view of mkannotationview.
OnBackgroundAfter updating the subtitle, if you do not manually click another mkannotationview and then click back to the mkannotationview that has previously shown calloutview, the subtitle in the calloutview of this mkannotationview will not be updated ......
Clearly, after you click a pin to display information, if the background updates its subtitle, then you click the pin to find that its subtitle is blank. Click another pin and then click back. The information of the pin is complete.
Although one notification is mkannotationcalloutinfodidchangenotification, the SDK manual says this is no longer usable. I tried it and it didn't work ......
I don't know if there are other methods.
The answer is as follows:
Reference the 22nd floor cjlin published on:
6th questions...
If mkav is selected by using the marker, then...
If (mkav. Selected)
{
[Mkav setselected: No];
[Mkav setselected: Yes];
}
In this case, the subtitle will be updated. [url = job. php? Action = topost & tid = 17969 & pid = 138830] [/url]