Auto Zoom in for a cluster of map markers - ios

I have multiple map views and each view has a group of map markers
e.g. Map View 1 = 4 map markers, Map View 2 = 10 map markers, Map View 3 = 20 map markers.
In most instances the map markers are a few meters from each other and in other instances they are a few miles apart.
Is there an easy way to set the Map View such that it automatically zooms in such that it encompasses the map markers in each view. If i have to do it manually no amount of zoom level will never be perfect.
An alternative is to define a center and a custom zoom level for each map view but that sounds a bit tedious.

There is no automatic function for doing this - you can calculate the bounding box corresponding to the POI cluster (i.e. find the top left lat and long and bottom right lat and long) and zoom to that bounding box.

Related

Here Map : How to differentiate between two markers at same location

How can we differentiate among multiple NMAMapMarker at same location.
As we have marker.userdata property for google markers but how to manage data for markers in Here Maps.
When you are placing multiple markers at the same geo-point, they are stacked on top of the other. Since they are all at the same coordinate, only the top most one will be displayed. To enable multiple marker to be shown at the same coordinate, you will need to have some logic to slightly shift the position of markers. For example check if there is already a marker at the point, if there is an existing one, then use some logic to slightly change the coordinate value of the new marker to be added at the point.

Polygons in Google Map

I construct three polygons in the google map using the help polygons in google Map API for developers site. They are look like one polygon inside an another polygon .When my page is loaded all three polygon are loaded.How can i get the inner polygon when the outer polygon is zoomed or clicked in google map?Image:polygon inside another polygon
Your polygon are just place in postion that appear as one is inside another
for google maps the way you place your polygon had not a topological meaning
A easy eay for avoid that a larger polygon is over a small one could be based on z-index
assignin z-index with higher value to the polygon over the others eg:
// the larger - at base
var polylgon1 = new google.maps.Polygon({
...
zIndex: 100
});
// the middle - at medium leve
var polylgon2 = new google.maps.Polygon({
...
zIndex: 200
});
// the smaller - at top leve
var polylgon3= new google.maps.Polygon({
...
zIndex: 300
});

How to add polyline in bottom half of the map view iOS 7

Please see below image:
As you can see, I added a mkpolyline to my mkmapview but because the route is to big so part of the route has been move behind the other subviews.
I want to make a change so that for all times, the positions of the poly-line be at bottom half of the map view(at below of the uitable that shows step instructions). Is it possible?
You need to zoom the map view out in order to have the route displayed below the route text view(s). There are 2 ways to do that generally:
Determine the new MKCoordinateRegion (or MKMapRect), which is the bounds of your route with extra padding space above
Change the MKMapView frame such that it sits below the route text views and maintain a region which fits the route
Option 2 is easier, but has a different visual effect. Option 1 requires you to pad the display area while maintaining the route display area.
For option 1, use the fact that you already zoom the map to the route and manipulate the visibleMapRect. Try:
MKMapRect visibleMapRect = map.visibleMapRect;
visibleMapRect.origin.y = visibleMapRect.size.height;
visibleMapRect.size.height *= 2;
map.visibleMapRect = visibleMapRect;

MKMapview zoom level within Kilometer

i have a application which has 3 things in UIViewController
MapView
Search-control - (Ability to Search any Location in Map view)
Slider - (minimum value 0km - Maximum value 50Km)
Now i have Searched one city Lets Say Barcelona . it will search using Geocode method and i got the latitude and Longitude of the Barcelona and i have added one annotation of red Pin which show title and sub locality in annotation click..
i want to calculate distance of Zoom in zoom out with in the Radius of that annotation in Kilometers. what are the best possible way to achieve this ?
For e.g. i want to zoom around 30 km within that Radius
Any help will be greatly appreciated
Calculate a MKCoordinateRegion with the searched point as the center and 30km(or whatever distance) as the radius,
see this to do it. Set the map region to the calculated value using this method
setVisibleMapRect:animated:

Marker unclickable underneath a polygon

I have a fusion table which combines markers and polygons. Sometimes the markers are layered below a polygon and are unclickable. Is there a way to force a marker to appear ABOVE the polygon, so both are clickable?
Example table ID: 3821195
Location is Toronto, Canada. If you zoom in tight, the marker is buried below the polygon.
I've experimented with creating different tables, entering the marker first, or entering the polygon first, but in some cases (eg the table above) the marker is alway underneath the polygon. How come, and how to solve?
Thanks,
Wendy
In the end I put the polygons in one table and the markers in another, and then stacked the layers with the polygon layer on the bottom.
This is the part of the script where the order of the layers were set:
layer1.setMap(map);
layer2.setMap(map);
layer4.setMap(map);
layer3.setMap(map);
First one listed is on the bottom. Last one listed is on the top.
Hope this helps somebody else.

Resources