How to remove GMSPolygon from GMSMapView - ios

Does exist any way to remove GMSPolygons from GMSMapView?
It does not seem to exist a property of GMSMapView containing them (as GMSPlolyLines), should I clear the map and render all again?
thanks

When you create the GMSPolygon you set its map property to add it to the map. To remove it from the map, set its map property to nil. This means you need to keep your own record of the polygons which you've added to the map, which you want to be able to remove later.
For example mySavedPolygon.map = nil

From google maps document
clear Clears all markup that has been added to the map, including markers, polylines and ground overlays.
So you just use
[mapView clear];
This should clear the polygons.

This has been updated, has I am using the clear function, and was looking for a way to keep the polygons while using this.
I've just confirmed against the Google Maps API Reference.
Clears all markup that has been added to the map, including markers, polylines and ground overlays.
https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_map_view.html#a28e6b8aeb7c8dc9025dc001f2a5d2c9b

Related

Shadows in pin annotation

Why when I load my pin annotation in map, my pin annotations have different number shadow? Some have no shadows and some have many shadows.
I receive the data for pin from the firebase.
How to remove shadow or how to make a small shadow in all pin?
Check image
The darker shadow means you have multiple pins in the same location. There are two main causes for this and depending on the reason, there are two ways to solve this:
1. The data contains multiple elements with the same location.
Consider using clustering, which will display the number of annotations in the location. This will be a lot easier for the user to understand than a darker shadow. :)
Here's a tutorial from Apple: Decluttering a Map with MapKit Annotation Clustering
2. You forgot to erase the annotations before adding them again.
Remove the annotations before adding them to the map again, for example when you're refreshing the view.
mapView.removeAnnotations(annotationsToRemove) where annotationsToRemove is an array containing the specific annotations you need to remove.
Or, if you want to add all the annotations again, you can remove all the annotations with
mapView.removeAnnotations(mapView.annotations)

iOS How can I move googlemap marker to the front?

I added two marks on Google maps. Now the two markers are overlapping. I want the selected marker to be always in the front. That means when you select a marker this marker covers another marker. I looked at the Google maps development documentation, which does not provide the relevant API.
How can I do this?
A simple resolution is using the propertie zIndex, just set to 1.
customMark.zIndex = 1
For more informations, you can see https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_marker

Drawing polyline in realtime

I'm fairly new to ios and I would like to know what would be the best approach to draw polyline on google map while user is on the move. So it would only show the path the user has traveled. I'm thinking about using current location as the destination and redraw the polyline as user moves.
EDIT : I'm not even sure if google map is the way to go for this particular scenario since this app is free and there will be fee for API call over 2500 times/day. Is it better to go with Apple Map?
Following these guidelines:
You need to create a GMSMutablePath and add the current user location. As the user moves you add more coordinates to the GMSMutablePath.
When you need to draw the line just instantiate a new GMSPolyline object and set the map property of the GMSPolyline removing the previously drawn polyline setting it's map property to nil.

GoogleAPI Marker not allowing on Ocean or See

I want to put a marker on a GMSMapView. But i don´t want that the marker will be displayed on ocean or see, only earth. I searched but i don´t find an attribute or method to detect if the surface on GMSMapView is see, ocean or earth. If there is propositions? I worked under XCode, and language Objective-C.
Do you need this to be global or is there a specific location you need?
You can use Google Maps Elevation layer to get if this location is above or below sea-level.
But some places have land that is below sea-level, so this solution would not always work.
https://developers.google.com/maps/documentation/elevation/intro

How to put my own map in MKMapView

I need create an app for iOS using the GPS and MapKit. The idea is create my own map of my house for example and add it to the UIView or MKMapView and see the current position into the map.
see the image
You can use custom overlay on the map. Here is nice example of image overlay on the mapView.
Apple has provided sample code to do this with map tiles. Using the MapKnitter website you can geoposition your floor plan and export it in a format that Apple's code will accept.

Resources