Problem when same lat lon are passed on mkmapview - iphone

I am having a mkmpaview in which i show different annotations based on address .I dont get any problem whne all the alat lon are different , but whenever i pass the same lat lon pair then instead of showing two annotations like google maps it shows only one pin .
My scenario is like say i have array of lat lon which is pass for adding annotations , the problem occurs when two pair of lat lon are same if three pair are same then also it shows only 1 pin for the 3.
IF someone has came across the same problem , please help me with that solution .
Any suggestions for different approaches would be accepted .
Hope i am clear with my question.

Your question is not very clear, but i will try to interpret what exactly you are asking.
I believe you want to use different annotation images , for the annotations you are adding that have the same longitude and latitude.
The approach isn't very clear, what exactly is the point of adding multiple annotations with different images in the same location?
You could load the annotations more than once, with different images, but i don't think this would have much sense.
You could also assign tags to the annotation images, and call both tags when loading the annotations on map view.

My answer to this question is very simple!
1) First detect each "same" latitude and longitudes.
2) When inserting pin to that particular location (latitude and longitude) use different color pin.
3) When tapping on pin, check the location of pin and if that belongs to one of the locations that we previously identified, write code appropriately to notify user.
Suppose you are displaying address on a label(on annotation view) when tapped on pin. And when you tapped on pin where there are more than one location assigned, try to display addresses on a scroll view so user can determine all the addresses. This way use some simple logic to tackle the situation.

Related

Strange behaviour of MapKit pin Annotations

when i am placing 5 pin on mapView with same address but callout bubble is shown only for two pin when the we taps a selected annotation view. When i tap pin then callout display only for two pins.
How to resolve this, i want to show callout of all pins even they have same address.
This happens because the zoomlevel of your map is not proper as per your coordinates requirements. Although you have annoted five pins at same address there should be minor difference into coordinates, to get separated.
You should work on longitudeDelta & latitudeDelta to get over this.
For ex. You can set
<coordinate_object>.latitudeDelta = 0.04;
<coordinate_object>.longitudeDelta = 0.04;
The lesser the delta value there is higher a zoom level and vice-a-versa.
Enjoy Programming!
Before adding each annotation to the map you should check if there is already another annotation at the same place, or within a few meters. If so then combine the data for these annotations into a structure that can keep growing (NSMutableArray is my first guess) and then add that combined data as a new annotation*. Then when the pin is tapped it will ask for the call out details and tell you which annotation was tapped, you can check if the annotation has one datum or multiple data at set up your callout correctly.
You'll need to have a custom annotation class but you would probably have needed that anyway if you're storing useful data about each one.
*you'll also need to ensure the first annotation is not left on the map, so maybe you could do a scan through your data and combine into arrays before doing any annotation stuff. Each annotation would store an array of values, most of them would only have one, but where they are too close together the array would have many values and your callout function would have to display that.

how can I set zoom level of map according to values of all lat long ,so I can see all that places in map iPhone?

I am getting lat longs of different locations,and I want to set zoom (span) in a such a way that I can see all (locations) pins on a map.
Pretty much a dup of Positioning MKMapView to show multiple annotations at once.
I found https://stackoverflow.com/a/7642526/191215 the most elegant.

Change annotations inside MapKit view

I have a lot of annotations to manage inside the mapkit view.
The rules are :
1 -only show annotations when the mapView.region.span.longitudeDelta is above 0.042
2 -only show annotations inside the visible area.
3- remove the annotations when they comes out the visible area...
How I can do that ... Share your experience...
Thanks
You need a few things. One is to search your database for the pins with latitudes and longitudes inside the map's view. This is called a bounding box. The next is to remove the annotations when they move outside the visible rect of the map. Each time the map is moved, you'll have to recalculate what pins are in the box and what pins are outside but still on the map.
One hint I can give you is to divide the visible rect of the map into squares (maybe 17 x 23 squares of 20 x 20) and figure out if a pin goes into that square. If it does, mark that square as filled, and if another pin wants to go into that square, don't let it. This will allow you to filter the pins so there aren't too many on screen at one time.
It's not an easy problem, but if you do some search around you'll find your way through it. This cluster marker code for Google Maps might help.

Translate GPS coordinates to location on PDF Map

I'd like to know (from a high level view) what would be required to take a pdf floor plan of a building and determine where exactly you are on that floor plan using GPS coordinates? In addition to location, the user would be presented with a "turn by turn" directions to another point on the map, navigating down hallways, between cubicles, etc.
Use case: an iPhone app that determined a user's location and guided them to a conference room or person's office in the building.
I realize that this is by no means trivial, but any help is appreciated. Thanks!
It's an interesting problem. When you're using Core Location, you're not necessarily using GPS. Using WiFi and cell tower triangulation, you can get pretty good location results. So from Core Location you get a latitude and longitude fix. (You might also get altitude info, since GPS data is 3-dimensional. You also will get an accuracy value.)
So you have lat and lon. You need to map these coordinates to the PDF plan's coordinates. Assuming that the plan is aligned with the latitude and longitude lines, and that you have a lat-long fix for one of the points on the plan, you need to calculate the x-axis scale and y-axis scale. Then it's some calculations to map the lat-long to x-y coordinates on the PDF plan.
GPS may not be accurate enough for this purpose, especially indoors. Assuming errors on
the order of 10 meters, you'll have difficulty determining which floor the user is on.
Here's a neat (?) idea that might work: can you post some "You are here" placards
at various locations around the building? You could label each one with a unique,
machine-readable location code (maybe a QR code or something similar), then take an
image using the camera, have your app read that image and interpret the location code,
and use that instead of GPS to determine the start location.
GPS inside? That's your first -- and biggest -- hurdle.
Next hurdle is knowing the GPS coordinates of at least three points on that PDF to define the plane of of your map in the real world. (The PDF will need to be to scale, of course.)
So that gives you where you are on the PDF. Now you'll need to figure out some way to determine where you can walk (or where you can't) to get directions.

Why does a pin placed at the same latitude and longitude in MKMapView differ from one in Google Maps?

I drop a pin in an MKMapView with longitude and latitude. When I place same longitude and latitude on google map the pin on both are slightly different.
I have a web/iPhone app that renders a map for positions sourced from the same database and haven't seen this issue. I would check your assumptions:
Are you truncating your values over the wire?
Are you rounding the position values differently on the two platforms?
Check the values you are passing into Google Maps and MapKit by logging them and comparing.
You can see from the following screenshots that the same latitude/longitude are rendered on the same position on the map:
Update
I tried the coordinates you mentioned in the comments and got the same position for both. You need to check your assumptions. The values that you are using on the web or on the device are not the values you think they are: