iOS Google maps dynamically update/remove programmatically created markers - ios

I am stuck with some lack of xcode / iOS programming knowledge.
I have created a track in google maps for iOS, and programmatically created markers along this track. What I would like to do is update these markers with actual information in the .title / .snippet (ie. distance to go, time to go etc) or remove them all together.
But when you create markers in a loop there is no way of keeping track of them.
since the amount of markers can vary from 2 to 50 it would be strange in my opinion to create 50 different variables for each marker, I guess there must be another way?

You can keeping track of created markers.
Each GMSMarker has property userData. You can add some string tag or other custom object to identify this marker.
e.g.
marker.userData = #{#"key" : #"some tag"};

Related

ARToolkit Multiple Mandatory Markers

I studied the multimarker documentation of ARToolKit for iOS and i have some troubles in achieving some sort of QR-Code.
I want, for example:
A set of 6 markers positioned differently on a picture, and when and only when ALL of them are present, some sort of video is displayed in the origin of them( i want to use some sort of CORNER Markers like QR-Code system ).
How to do this ? From what i've seen, on multimarkers, if 1 is present out of 6 for example, the object is displayed.
From looking into the ARToolKit code you can see that a MultiMarker is internally handled as one single Marker consisting of several Pattern:
https://github.com/artoolkit/artoolkit5/blob/master/lib/SRC/ARWrapper/ARMarker.cpp#L344
https://github.com/artoolkit/artoolkit5/blob/master/lib/SRC/ARWrapper/ARMarkerMulti.cpp#L75
That is why ARToolKit will always return true whenever one of the markers configured in the multi-marker configuration is visible.
Taking that into account ‘Multi-Markers’ are not the way to go for the target you would like to reach.
What you can do, however, is to configure each marker separately and add them as ‘Single-Marker’. Then you can query if all of these ‘Single-Markers’ are visible.
If so you can calculate the origin of all these ‘Single-Markers’ and render your object there.
You can get an idea on how to configure several ‘Single-Markers’ if you take a look here:
http://augmentmy.world/moving-cars-augmented-reality
Also take that example here on how to set to markers into the same coordinate system (and calculate the distance between them) you can use that as a starting point for calculating the origin between several markers:
https://github.com/artoolkit/artoolkit5/tree/master/AndroidStudioProjects/ARMarkerDistanceProj
I know that these are not iOS examples but I have only done Android so far. Also, the ARWrapper interface should be the same on Android and iOS, meaning to say there should not be much difference between these two.
I hope that helps

iOS - Nearby Places on Google Maps

I am working on a feature of my app that lets the user search for nearby pharmacies. I am trying to keep things simple and i would like to display the standard places icons and labels which are shown on google maps app. I searched extensively but i haven't found a way to do it. Is there a way to display all the pharmacies as standard ?
Currently i created a GMSMarker for every pharmacy found on a radius of 5km with custom icons and a custom label for the title. But i ran into issues when zooming out, the icons and titles keep their size and overlap.
You can assign position for the markers, so that it will be shown till there
GMSMarker *marker = [GMSMarker markerWithPosition:position];
Hope this works for you.

Adding Multiple Markers To Google Map on iPhone app

I am writing an iPhone application that uses google maps SDK to display a city. I need to add multiple markers on the map to identify certain locations.
I could loop through and add each marker upon the map load, but I don't believe this is a efficient technique(it seems very unnecessarily and resource heavy!!)?
Or is there some "Lazy loading" technique I could use to pull in the markers that are currently in view?
For that you can add it in map region wise, you have to add marker only for current displaying map region, but for this also you need to run loop.
So you can avoid other markers that would added to map.

iOS MapKit - defining irregular touchable regions

I'm working on an app that lets a user select locations on a map. The entire map is subdivided into irregular regions (administrative boundaries), and when a user touches a point on a map, I need to be able to figure out which region the point belongs to. Just to clarify, there is no finite set of points for a user to choose from, they just tap anywhere on the map.
What is the best way to achieve this? I have been looking at MKPolygon class but cannot really figure out if this is the way to go. If it is, would I be using intersectsMapRect: method of the MKOverlay protocol to check for a match? Are there any good tutorials on this kind of map operations?
A good approach here might be the MapBox iOS SDK and it's RMInteractiveSource, which is designed for this. Check out this sample app which shows interactive regions.
This is done by a space-optimized, offline-capable key-value store of sorts that keys pixels at varying zoom levels to arbitrary content values (region name, data, imagery, etc.)
In MapKit proper, you'll need some sort of spatial analysis (maybe Spatialite?) to determine intersections between points touched and irregularly-shaped regions.

Clustering Google Maps Markers in iOS

I have a map-based application, using Google Maps' iOS SDK. I need to store up to several thousand items in a core data database and display them with markers on the map. For performance and usability reasons, I need to cluster these markers when the user is zoomed out, but I need to make sure to place representative markers so the user knows where to zoom in to see more detail.
Each entry in my core data model has latitude/longitude double values stored. So what I thought of for clustering the items is to keep a separate entity where I strip the less significant parts of the geographic coordinates and store a count in it.
So whenever an item with lat/lon {44.9382719, -130.20293849} is inserted in the database, another "cluster" object with lat/lon {44.9, -130.2} has its count property incremented. The idea is that at low zooms (ie. zoomed out), I would only query the cluster objects and place those on the map instead of the actual items.
My question is: according to the NSManagedObject reference, you're not supposed to fetch stuff in awakeFromInsert, so how can I make sure that inserting a managed object of one kind updates the value of a corresponding managed object of another kind?
I have been searching library for Clustering Markers in Google Maps for iOS for three days, and finally I ended up with this https://github.com/googlemaps/google-maps-ios-utils, which is working nicely and very easy to use and understand.
Have a look at routeMe, this comes default
/** Whether the annotation should be clustered when map view clustering is enabled. Defaults toYES. */
#property (nonatomic, assign) BOOL clusteringEnabled;

Resources