How do I draw a geofence on a map? - ios

Does anyone have any good sources for me to read on how to draw a geofence on a map in an iOS app?
I want to learn how to freeze a map on a view and allow a user to draw a square, circle, or polygon to set up a geofence.
Thanks!

As of iOS 7, a geofence (CLRegion) can only be a circular region.
CLCircularRegion
If you want to draw on a map view, you can add a transparent custom view on top of the map view and handle the touch events on the transparent view.

Related

Can we add the custom view or the pulse ring animation around the marker in google maps

I have to add a pulse ring animation around a marker. As I see there is only NSObject in GOOGLEMAPS so we cannot add up a view . I have also tried to change or animate the scale of the marker but the scale change did not happen. Can anybody help me with this thing?
I've worked quite a bit with clustering markers with Google Maps for iOS SDK. GMSMapView uses OpenGL to render the markers on the map corresponding to the data points added via GMSMarkers. They provide a basic pop animation on appearance, but nothing else.
Without tracking GMSMarker movements and adding/keeping track of your own UIViews on the GMSMapView, this doesn't seem possible. GMSMarker lets the user specify a UIImage to replace the default marker image, but not animate the rendered UIImage, as the GMSMapView is backed by OpenGL. It is quite limiting- clustering markers was difficult because you cannot replace the default GMSMarker image with just a UIView. It HAS to be a UIImage.

Maps on iOS: Drawing layers without showing the base map

We are looking for a drawing / mapping SDK for iOS with the following requirements:
Draw multiple polygons on a single view. polygon coordinates are based on earth lat/long
Do not show other map layers from satellite / street view / whatever - just the polygon data
Allow adding layers / text/ bubbles / etc.
Allow zoom in-out
Allow clicking on regions.
Calculate bounding rect automatically, and do not allow the user to scroll out of this area.
Is there an SDK that supports these requirements?
Thanks.
Check out the Mapbox iOS SDK. It's open source, allows you to hide the basemap (or create a custom basemap to whatever appearance you desire), constrain the panning and zooming, add vector polygons atop the baselayer(s), add text and labels, control interactivity, and more.

MapKit uber style map Center annotation

I would like to have a annotation in the center of the map, that does not move when the region is changed. That is, when one moves the map, the annotation stays in the center regardless. I have implemented this using NStimer, assigning the map center coordinate to the annotation every .001 seconds, however this is very choppy and doesn't look smooth.
I realize that I need to use an Overlay than convert the overlay annotation to coordinates on the map.
Pretty much it would look like what Uber has.
THe other solutions for this that I have seen have not used a normal annotation. Instead they put another view over the top of the map with the annotation image in the middle. It doesn't matter what happens to the map the view stays centered on the screen and if you do ever need to interact with it, you just ask the map what the center coordinate is at that time.
You can get the code from the following link:
https://github.com/scottrhoyt/CenterPinMapViewController

MKMapView - Is there a way to use MKUserTrackingModeFollow with a modified center/focus?

I have a MapView that takes up the full screen and a few elements toward the top of the screen that overlay the map. These top elements potentially cover the blue location marker.
The map is currently tracking fine with MKUserTrackingModeFollow, but I'd like to move the tracking focus down about an inch (obviously the metric will vary by zoom level) to ensure the marker isn't covered. Is there a way to do this with MKUserTrackingModeFollow?
I've considered moving the map with the top elements, but due to design constraints this isn't an option.
Instead of using the userTrackingMode of the MKMapView object to follow the user's location, you could set up a delegate of CLLocationManager to receive location tracking events, and with each location update event you receive, set the center coordinate of the map view, with your vertical offset added to the coordinate value.
You can use the various Map Kit functions and MKMapView methods to convert your offset from some fraction of the map view's bounds.height to a MKMapPoint or CLLocationDistance value.

Show circle around selected location

As we have seen there is a circle around current location in iOS mkmapview. Is there any way to draw a similar circle in mkmapview for location other then current location?
If you look at the documentations for MKCircle: http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKCircle_class/Reference/Reference.html and MKCircleView: http://developer.apple.com/library/iOS/documentation/MapKit/Reference/MKCircleView_class/Reference/Reference.html both of which are part of the MapKit API,
you'll find tools for drawing circles!
As mentioned at this link Circle around a point on an MKMapView
there are no easy way to create animations for these circles, however the advantage is that they will provide you with a degree of accuracy for your coordinates on your map!
The steps to creating the circles, one way, is here: Drawing a circle on mapkit
Basically, create an MKCircle object using circleWithCenterCoordinate:radius: method and add it to your mapView (using addOverlay: method)
Next, in the mapView delegate, implement mapView:viewForOverlay: method, create and setup MKCircleView instance there and return it.

Resources