How to draw a circle on MapBox MGLMapView? - ios

I'm using MapBox SDK 3.1.1 for iOS, and it doesn't seem there's a way to draw a circle as an overlay (Polygons are included as primitives)
There used to be a way on the legacy SDK, but it's no longer maintained.
Can someone provide insights?
thanks!

If anyone is interested, there's currently no replacement for RMCircle (present in in 1.x version) in the 3.1 SDK.
There's a workaround described here, that uses MapBox annotations
https://github.com/mapbox/mapbox-gl-native/issues/2167#issuecomment-169265375
Look for
- (MGLPolygon*)polygonCircleForCoordinate:(CLLocationCoordinate2D)coordinate withMeterRadius:(double)meterRadius

In addition to what friedbunny suggested (and based on info in the link he posted), you can fix the zoom level, and use metersperpixelatlatitude to make an image of fixed size for your annotation. Then, use the imageForAnnotation MGLMapViewDelegate callback to provide the "overlay" as the MGLAnnotationImage.
If you want to change zoom levels with this method though, you're looking at some pretty tricky juggling of delegate methods and possibly several minor hacks.

Related

Animated Marker on Mapbox

It seems that mapbox updated its ios SDK recently with some huge change.
For example, it seems that it is not possible anymore to provide a layer as a custom marker, or to animate a marker as in this example:
https://www.mapbox.com/mapbox-ios-sdk-legacy/examples/cakeyframeanimation/
It seems that every reference to that example is related to a RMM* named class which has been deprecated.
How can I implement an animation in a Mapbox's MGLMapView?
Any kind of suggestion is appreciated, from a series of png to a CAEmitterLayer, to a generic view to be used as a marker so that I could do anything I want with it.
View-based annotations/markers is a feature that will be coming in the v3.3.0 release. Once you’re able to use views, you’ll also be able to use the same Core Animation methods you’re familiar with.
If you would like to try out a pre-release version of v3.3.0, have a look at alpha 3, which has preliminary support for view-based annotations — see MGLAnnotationView.

Mapbox: Custom Annotation Callout

In mapbox for ios using swift what is the correct way to create a custom layer in the annotation bubble using the new Mapbox for iOS I know in the previous version you could get something similar following this link but the new official version seems pretty different. Also the intention is to change the callout, possibly just displaying a UIView in its place
The callout uses the same dependency as the old SDK, which is SMCalloutView. It should be just as customizable as in that guide you linked to.

How to make a pull-up View in iOS (similiar to FourSquare)

I want to make a a sliding up like FourSquare app.
Like this:
What I want to achieve are:
The UITableView goes all the way up to UINavigationBar.
It drags along with my finger's position.
My app also have a GMSMapView below (Google Map's API, similiar to FourSquare), I don't want the map responses to my gestures on the UITableView, I want it stays still.
Works both in iOS 6 and 7 and iPhone 4,5.
Does anybody have a framework, github's link ... that can help me fulfill this ?
Thank you.
I have been working on something very similar in the past days. This answer is actually quite good, but you will suffer a bit in terms of performance. After more tweaking, I used parts of this library. You don't need to use everything, but keep in mind the following when choosing a library:
Libs that base the movement of the map on the map.centerCoordinate are less performant than libs that base the movement on the map's frame.
You can also read a bit from this tweets exchange I had.
My thoughts about what FourSquare actually did, is that in the beginning they are using a screenshot of the map, so they are not really using a MKMapView, but an UIImageView. Once you touch it and you animate it, they switch between one and another and they start using a map. I will be using Reveal App plus this to know exactly what they are doing.

Applying annotations to map kit

My problem is that I cannot find any up to date tutorials with iOS6 and map kit that include storyboards instructing you on how to apply annotations/pins with the use of for-ordinates.
My homework tells me that the tutorials out there are xib, iOS 5 related which now defeats the point because apple implemented their own maps with ios6 and are no longer using Google's..
I've used google and checked out apple's developer's guide..
I can't be the only one searching for this answer...?
Many thanks.
The MapKit API is essentially same between iOS5 and iOS6 - what changed was the source of the mapping data, the graphic design of the maps, and the use of vector data over bitmap data. But most of this is opaque at the API level. Between iOS versions you continue to use the same framework and classes. There are a few additions (such as MKMapItem, routing) and a few simplifications, but any code written for Apple's iOS5 MapKit SDK will work with iOS6 MapKit.
Issues of xib vs. storyboard tutorials are not specific to MapKit, and nothing in MapKit relies on one or the other, so you shouldn't allow that to confuse you. However, here is an iOS6 tutorial to get you started:
http://www.raywenderlich.com/21365/introduction-to-mapkit-in-ios-6-tutorial
For an overview of changes between ios5 and ios6 MapsKit, take a look at the WWDC video from 2012,Getting Around Using Map Kit.
so by using the code below, I've manage to place one pin by using coordinates and placing it in viewDidLoad, but when the code is copied, it fails to build. Any solutions for adding multiple co-ordinates?

iOS Google Maps Api Tiled Overlays

My app currently is using the google maps api v2 for iOS. I would like to add custom tiled overlays, which I realize is not support by the api.
The first approach I took to this problem was to try to extend the GMSOverlay class but I later found that the drawLayer method was never being called.
Next, I tried having my custom class extend UIView and then add my class as a subview to the map view. I was able to use the GMSMapViewDelegate method didChangeCameraPosition to report camera updates back to my custom class so that the tiles could be redrawn. This mostly worked with a couple exceptions, first, only the initial set of tiles would load, and if you panned or zoomed from the initial X,Y,Z the map tiles would not update via the drawInRect method. The second problem was that my custom UIView was covering all the markers and their corresponding callouts after tapping.
My question is, does anyone having any experience adding custom tiles or subclassing the GMSOverlay class to add, for example, custom weather tiles over top of the google map?
Good news from the release notes of v. 1.3.0 of Google Maps SDK for iOS (released today):
Support for custom tile overlays (image-based) via GMSTileLayer.
See: https://developers.google.com/maps/documentation/ios/releases
Have you tried looking at this example?
https://github.com/mtigas/iOS-MapLayerDemo
It is based on the MKMapKit, not the Google-Map SDK. It supports tiles with zoom and is very easy to extend, and might point you in the right direction.
If you need to generate tiles for the map, you can use MapTiler
http://www.maptiler.org/
The Windows version of MapTiler gives more fine grained control of the tile generation.

Resources