Customize GoogleMap from IOS API - ios

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;

Related

Objective-c, Google Maps draw a polygon within radius of 50 Kilometers from my current location

Hope all are doing well.
In an on going project, am using Google Maps and need to draw an overlay like the below attached image, where the overlay covers the radius of 50km region from my current location.
Appreciate your help, I've tried few links which show same like
Inverted Polygon in GMSMapView

iOS : How to load Hebrew map?

I am working on an app where i need to load hebrew map and also update map as location change and draw path from initial location to change location.
I have worked on apple map and google map. But i find some difficulty in loading israel country map on it. Is it possible to load such map on iOS? Any suggestions are most welcome!
To load hebrew map
Based from this SO question, Google Maps iOS SDK uses the system region/language settings but doesn't expose any way to manually force any particular language. Geocoding responses (using the SDK classes) and the map labels both reflect these device settings, thankfully.
Draw path from initial location to change location
You can use Polylines 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 create a polyline, you'll need to specify its path by creating a corresponding GMSMutablePath object with two or more points. Each CLLocationCoordinate2D represents a point on the Earth's surface. Line segments are drawn between points according to the order in which you add them to the path. You can add points to the path with the addCoordinate: or addLatitude:longitude: methods.
Example:
GMSMutablePath *path = [GMSMutablePath path];
[path addCoordinate:CLLocationCoordinate2DMake(-33.85, 151.20)];
[path addCoordinate:CLLocationCoordinate2DMake(-33.70, 151.40)];
[path addCoordinate:CLLocationCoordinate2DMake(-33.73, 151.41)];
GMSPolyline *polyline = [GMSPolyline polylineWithPath:path];
You can check this related SO thread.
Loading israel country map
Check these links:
How to get country specific result with Google autocomplete place api ios sdk?
Is there a way to display a single country in Google map? It should be only one country, not parts from other countries included
Hope this helps!

Google maps iOS SDK level of detail polylines

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

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.

Google Map's marker not being displayed properly

The app I'm working on has a map which contains a circle on top that resembles the area that will be searched plus it shows the area in miles on top. In order to calculate the area covered, I need to find the radius of the circle after the map camera has changed (or in Apple maps terms, when the region changes). In order to test that the map is getting the right destination/length of the radius , i'm placing a marker at it's center and a marker at the boundaries of the circle. After that i calculate the radius and continue to calculate the area. I was working with Apple maps first and everything worked fine and now i switched to Google maps in order to use Places API and other API's. In Apple maps the deltaLongtiude and deltaLatitude from the region made it easy to calculate the changes when the region has been changed. In Google maps, they use Camera instead of Region. it has no deltaLatitude/Longitude (correct me if i'm wrong). I'm using the same equation here to calculate the distance using cross multiplication. When i zoom out of the map and drag the map, the center mark is placed correctly however the marker on the boundary is misplaced. Please find the code below of what I'm doing.
In viewDidLoad: i set up the map as follow:
GMSMarker *currentLocation = [GMSMarker markerWithPosition:CLLocationCoordinate2DMake(latitude, longitude)];
currentLocation.map = _map;
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude+0.0075 longitude:longitude zoom:13];
_map.camera = camera;
[_map setMinZoom:1 maxZoom:13];
The 0.0075 is just to adjust the camera properly.
Now in order to view if the markers are placed correctly, i use the following delegate method:
- (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position{
GMSMarker *currentLocation = [GMSMarker markerWithPosition:CLLocationCoordinate2DMake(position.target.latitude-0.0075, position.target.longitude)];
currentLocation.map = _map;
GMSMarker *currentLocation2 = [GMSMarker markerWithPosition:CLLocationCoordinate2DMake(position.target.latitude-0.0075, position.target.longitude + ((0.0172*position.zoom)/13))];
currentLocation2.map = _map;
}
currentLocation places a marker in the center and currentLocation2 places a marker at the boundary. In order to place the marker correctly in case the user zoomed out, I do a cross multiplication. Since at zoom level 13 the boundary marker should be longitude+0.0172 from the center marker, i multiple 0.0172 by the new zoom level and divide it by 13 and add the value to he longitude. When i run the app and zoom out and drag the map, the boundary marker is misplaced. It's somehow has the same coordinates of the previous zoom level. DO i have to update anything in order to make it work or am i doing anything wrong?
to view more what i'm talking about here are pictures. The first show the map at zoom level 13. As you can see a marker in center and a boundary marker. In the second picture it's at a different zoom level and as you can see the boundary marker stays in same place and doesn't add a new one on the updated camera.

Resources