ios mapkit markers load their images in unpredictable way - ios

So, i am using native mapkit and load markers in json format.When i parse my json i have a special parameter, which detects what image should be used as icon(from images.xcassets) for current marker.But every time i load it, smth goes wrong and image assigns in unpredictable way and when i scroll map to new position and then back, markers again change their icons .Moreover, the same algorithm works fine on android using native sdk.I don't think the problem is in parse algorithm, but in map itself.Any suggestions?

Have a look at reuse identifiers for annotation views. It sounds like you are reusing views when you don't want to be, thus the new image is never set.

Related

Place an image inside of a google maps marker icon

Currently the markers on my Google Maps Map view appear to look like the first picture I uploaded, however I need to find a way to add a thumbnail in the center of the image similar to the second view, I am unsure of how to do this as the thumbnail is dynamic so I cannot set it to a specific image like I am doing by setting the marker.icon to the icons bubble image. Has anybody attempted anything like this before? The thumbnails are being retrieved from a Parse server so I cannot prepare this ahead of time with code.
I had a similar problem in a project a while back. What I did to solve it, was in the javascript I started by making all the markers set to be hidden initially. As I added each one I added an eventListener to the src of the icon image so that when it loaded I could switch the marker on with setAnimation("BOUNCE") to make it look intentional. That's the idea and it worked for me. Let me know if you run into any bumps.

Add text under markers in mapbox ios

I'm using Mapbox SDK in my iOS app (using Swift).
I want a label to show under every marker like this:
I couldn't find anywhere in the docs or on stackoverflow how I can achieve that. I tried to make the text a part of the marker image, but the text does not resize itself that way and things are a mess when markers are close (or when you zoom out).
Does anybody know how I can make that happen?
Right now, you'll want to do this at the GL style level using Mapbox Studio — not as dynamic annotations.
Doing it in the style allows labels to be recalculated and customized based on the surrounding data and map state, whereas annotations currently aren't as customizable.

Make MapView display normal Apple Maps when I don't have a tile in my MKTileOverlay set

I am working on an iOS map that uses a "custom" map, stored completley in my application so it can always be accessed offline. I am using a custom MKTileOverlay URL to my local file store to make this happen, etc.
However, as my application's map only covers a small geographic area, I would like to have have the MapView display the standard Apple Map in such cases. When I overlay the map and set "canReplaceMapContent" to true, I just get a blank white space for map tiles that aren't present.
I don't really want to set canReplaceMapContent to FALSE, because most of the time a user will be using my (custom) map, so I wouldn't want the overhead of rendering the Apple map that would be completely covered.
Is there any way I can return a "nil" to a function or something to tell MapKit to not use the TileOverlay, and just use the regular Apple map instead?
No, but here's an idea: have two MKMapViews with the same frame, one with your custom map and canReplaceMapContent = YES and the other without and NO. You can hide one and show the other, transferring annotations if necessary, and you might be able to produce a convincing swap.

grabbing a screenshot from gmaps4rails

So yeah we're trying to display a pretty small version of the map and all the user interface elements were getting in the way.. and we realized a screenshot would probably be just fine, so just wondering if it's possible to generate a screenshot of a map position and just have it display as an image instead of an interactable map.
You can use Google Static Maps to show a non-interactive map without user interface controls (zooming buttons etc.)
As they return an image file it is easy to cache. Please note that Google does not allow caching of maps due to copyright reasons of the map owner, but probably caching is not necessary with the static map.

iOS mapview issue/question

I have an App I am developing for iOS, and the app does the following
Load and set annotations and launch corelocation and zoom to location.
There are a lot of annotations on the map, the loading from data doesn't take long, but the actual rendering of them them to the map takes a while.. so the user interface sort of stalls for a little bit, and then finally gets the corelocation and zooms to it.
While this is functional, it is less than ideal user experience.. I could invert the order, than do the corelocation zoom first and then call the add annotations, but this would cause a pause to the UI as well since annotations are added in the UI thread, and not to mention that corelocation could take a little time to get its location first too.
So, the question I guess I am asking is what is the best way to handle this? Is there some way I am unaware of to have the annotations render to the map without tying up the UI? I could show some sort of Splash Screen I guess over the map while this is going on, but that seems a cop out, and I personally hate splash screens.
Maybe the best way to do this is to show the BUSY/WORKING spinner over the map until its completed?
What is generally considered best practice?
You could use OCMapView to cluster all annotations. As already mentioned, the map can handle a bunch of annotations but the performance goes down with the number of drawn views and MKannotationViews don't make a difference.
OCmapView clusters all annotations and displays them merged in a single annotationView. try it out, it's free.
https://github.com/yinkou/OCMapView
I wound up simply doing the same thing I did with the android version, while iphone can handle the larger number of annotations far better than droid, the lazy loading approach certainly is a better overall experience for both platforms.
Thanks for the help guys.
I think your best solution would be to simply not add "a lot" of annotations to the map. MKMapView has a lot going on and it doesn't take a ton of annotations to bog it down. There are a number of creative ways that you can go about reducing the number of annotations.
If you have a lot of annotations that are grouped tightly together, consider aggregating them into a single annotation which then split apart into separate annotations when the user reaches a satisfactorily close zoom level.
Another consideration would be to default the user to a tighter zoom level and only add annotations that are currently on screen at that zoom level and position.
Do either of those options sound viable or get you thinking about another creative way to help your situation?

Resources