Google maps iOS SDK level of detail polylines - ios

I am using the Google Maps iOS SDK to draw a list of polylines. The polylines come from a server, and for each next polyline, the starting point corresponds with the end point of the previous polyline.
I notice that Google Maps changes the level of detail of the polylines at different zoom levels, probably an optimisation thing. This results in small gaps between the several polylines at lower zoom levels.
The reasons behind splitting a polyline up in several smaller lines are not up to me, this is what the system defines for me. I know I may be able to combine the several polylines into one single large polyline, but I was wondering: does the SDK allow the setting for this level of detail? Or is there maybe another fix?
Zoomed out, notice the gaps:
Almost fully-zoomed in, the gaps are nearly gone:

I have found no answer so far, so what I did, was traversing all geo-coordinates in-order (luckily my data-structure allows this), collect them in an array, encode this array to a Google Encoded Polyline (GEP) as per https://gist.github.com/mmdumi/3999640, and then display this on the map using [GMSPolyLine polylineWithPath:]. As far as I can tell, there is no way to instantiate a GMSPolyLine other than using a GEP.

I have found no answer too, but, there are two ways :
You can draw the entire line like a for sentence and draw, for example :
path.add(CLLocationCoordinate2D(latitude: latitude_,longitude: longitude_))
let polyline = GMSPolyline(path: path)
polyline.strokeColor = .red
polyline.map = mapView
polyline.strokeWidth = 2
or
https://github.com/raphaelmor/Polyline

Related

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

Customize GoogleMap from IOS API

I'm looking to customize the display of a Google map. Currently I'm using the 1.13.2 ios API but I'm fairly stuck. I need something close to mapType = kGMSTypeNormal but I must get rid of shaded areas, road names, and road numbers.
Can anyone tell me where I can get the source code for the ios API or suggest a strategy for removing these layers/views on the fly without modifying the source?
If someone knows anything better that Gmaps I'm open to suggestions. I must have building shapes and road icons as the app is designed to work with the building shapes. I'd use the Apple Map framework but it doesn't show the building outlines. Think Pokémon Go, but you are cataloging buildings.
The Google Maps SDK for iOS offers some simple ways for you to add shapes to your maps. You are able to modify the appearance of each shape in a number of ways.
The following shapes are supported:
A polyline is a series of connected line segments that can form any shape you want and can be used to mark paths and routes on the map.
A polygon is an enclosed shape that can be used to mark areas on the map.
A circle is a geographically accurate projection of a circle on the Earth's surface.
Polylines allow you to draw lines on the map. A GMSPolyline object represents an ordered sequence of locations, displayed as a series of line segments. You can set the color of a polyline with GMSStrokeStyle.
To customize a polylin, use GMSPolyline. It provides several properties to control the appearance of the line. It support the following options:
strokeWidth
strokeWidth
geodesic
spans
strokeColor
You can customize your map with one of several map types. A map's type governs the overall representation of the map. The Google Maps SDK for iOS offers the following types of maps:
Normal Value: kGMSTypeNormal
Hybrid Value: kGMSTypeHybrid
Satellite Value: kGMSTypeSatellite
Terrain Value: kGMSTypeTerrain
None Value: kGMSTypeNone
To set the type of a map, assign a new value to the GMSMapView.mapType property. For example, to display a satellite map type:
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
longitude:151.2086
zoom:6];
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
mapView.mapType = kGMSTypeSatellite;

Drawing Polyline on an ios Mapview

In my Xamarin ios app I have to draw the path as user walks,
I am planning to do this by drawing Polyline to a Map view by fetching Lattitude & Longitude from CClocationManager, But I have to deal with N number of Lattitude & Longitude in this case,
Is there any simple approach to do this? In our scenario We won't be knowing the destination , User will Just start a run from a point and we have to track his path on map by drawing a line, How could I do this?
A possible solution could be to save the current last known position, which also represents you endpoint of a polyline. On a location change use it as a starting point for the next polyline. That way you draw the route with multiple polylines piece by piece.

Draw a grid onto an MKMapView

I'd like to draw a grid into my map, that represents the size of a tile at a certain zoom level. So for example I'd like to have a grid on my mapview that shows the outline of a zoom level 10 tile. So the outline of where this tile would be. No matter if the mapview itself is at zoom level 5 or 15, it should display the outline of where that tile would be placed.
The problem I have is how to calculate the proper rect that represents each visible "tile".
Any help is sooo much appreciated!!!
Or maybe the answer to following question would help:
How can I convert a MKMapRect to a MKTileOverlayPath?
I find that MapKit is way too limited when you want to start doing more and more with maps.
I would reccomend using Google Maps SDK for iOS: https://developers.google.com/maps/documentation/ios/start
and then using GMSTileLayer for the tiles:
https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_tile_layer
In the long run, replacing MapKit with Google maps gives you far more features and options and has better geolocation and reverse geolocation than Apple
You can also look at Mapbox. Between using TileMill to create a grid layer by setting the Map background to a pattern image, you could then only export zoom level 10 and either host it on Mapbox or export it to MBTiles format (SQLite-based). Then one of the Mapbox mobile toolkits could serve the tiles out as an overlay on your map.

How can I implement the custom drawing search tool used in the Realtor iPad app?

The Realtor iPad app has done a very good job of implementing a custom drawing tool on top of mapkit that they use to query an area for homes. I am familiar with mapkit and its associated classes but I am unaware of how I could do some custom drawing with my finger and have it translate to a geospatial query. How to do it?
I'm not sure how far along you've made it with this, but your basic algorithm should look like this:
Draw a polygon overtop your map, then translate the coordinates of that polygon to "map" coordinates. In order to do that you would probably need to listen for gestures on a view other than the MKMapKit instance. With my limited knowledge of the MapKit's touch event handling you might have to overlay a different transparent view on the map when you want to draw, so touch events won't go through to the MapKit (if that makes any sense). You use your finger to pinch, zoom, pan and you won't want that functionality if you're trying to draw. In that view, you'll draw the shape tracing the user's finger, then translate the points drawn into map points.
The docs indicate that you can translate screen points to map points using the convertPoint:toCoordinateFromView: method on MKMapView.
Check this link for information on that: Trouble converting MapKit user coordinates to screen coordinates
This post provides a link that might help you with drawing the polygon:
To draw polygon on google map with MapKit framework
After you've drawn your polygon you'll want to "spatially" query your data. You could do that in several ways. Locally on the device or through a web service are two options. If your data is local to the device you'll have to do the cartographic math on your device. You'll also need to ensure that your point data (the X,Y's) are in the same projection and coordinate space as your polygon's information. Polygon intersection math is relatively straight forward to do, when your projections and coordinate systems line up.
Here's a link that can help you with the math.
https://math.stackexchange.com/questions/237/how-do-you-determine-if-a-point-sits-inside-a-polygon
Alternatively you could set up some web service that takes your polygon data and performs the same cartographic math on a server and returns the results to the device. Either way the same math needs to be performed. You'll take that polygon data and determine which records in your data intersect with that polygon.
This is pretty high-level, I know, but it should be all you need to do.
Another consideration is if your data is spatially enabled with spatialite compiled for SQLite on your device or SQL Server Spatial on your server. You should be able to query the data using that polygon data. You would have to format the query properly, though.
Lastly, I would encourage you to look into the ESRI SDK for iOS. ESRI provides drawing and sketching tools out of the box. Its not too difficult to use but one downside is that you would have to learn a new API:
http://resources.arcgis.com/en/communities/runtime-ios-sdk/

Resources