Strange behaviour of MapKit pin Annotations - iphone

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.

Related

User control of order of overlays in a Leaflet map

Is there a Leaflet plugin or example for letting the user control the display order of overlay layers in a map?
Turning layers on and off is working fine, but I'd like the user to be able to drag layer names within the layer control to set the Z order.
For Path class (Polygons, Polylines, etc.) there are methods 'bringToFront()' and 'bringToBack()'. You can't exactly set precise position in draw order, but iterating over layer list and calling 'bringToFront()' could be less time consuming, then re-drawing every layer (especialy if they are bigger).

MapKit: How Can I Transfer the Exact Same Projection to a New Instance With A Slightly Different Shape?

OK, here's the deal:
I have two views: simple and advanced. On the iPad, they come with a big-ass map view, with a marker that can be moved to indicate a position.
Each view has a different instance of MkMapView. When I switch from one to the other, I want to keep the map at exactly the same position and zoom level, so the user feels as if it is the same map.
However, the shape of the map view is slightly different for each of the views. This is because the advanced search has more stuff above the map.
When I open the map (this is code from an abstract superclass, so both instances get it), I set the region and marker position, like so:
[mapSearchView setRegion:[mapSearchView regionThatFits:[[BMLTAppDelegate getBMLTAppDelegate] searchMapRegion]]];
[myMarker setCoordinate:[[BMLTAppDelegate getBMLTAppDelegate] searchMapMarkerLoc]];
searchMapRegion and searchMapMarkerLoc are static, and reflect the currently displayed map's region and marker location (the center of the map).
Here's the problem:
Because the map is a slightly different shape, there is always a bit of adjusting. This can "bounce" back and forth, so that the map zoom keeps decreasing every time you switch, until you are looking at the whole world.
It doesn't matter whether or not I use regionThatFits. The same thing happens, even with this code:
[mapSearchView setRegion:[[BMLTAppDelegate getBMLTAppDelegate] searchMapRegion]];
[myMarker setCoordinate:[[BMLTAppDelegate getBMLTAppDelegate] searchMapMarkerLoc]];
All I want, is for the exact same zoom and center to be displayed. I don't care is the advanced view cuts a bit off.
How do I get the $##!! MapKit to stop tweaking the zoom factor?
Just FYI. I solved this by creating a custom model layer class that maintains the scale and center point, and is used by multiple MKMapViews. It works pretty well, but the MapKit does sometimes tweak the scale very slightly to fit one of its "detents."

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.

Problem when same lat lon are passed on mkmapview

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.

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.