Prevent GMSMarkers from Scaling on iOS? - ios

I am using GMSMarkers on iOS with the Google Maps API. I have a GMSMarker with a PNG image and no matter my zoom level on the map view the GMSMarker keeps its size respective to the screen. If I zoom in it is 30 points across the screen, and if I am zoomed all the way out on the map it is still 30 points. I do NOT want this to happen, I want the GMSMarker to stay small no matter what the zoom level is. It would be preferable that I do not have to loop through all my GMSMarkers every time the camera zoom changes, as I will be eventually having 50-100 of them on the map.
Is there anyway to keep the GMSMarker small no matter the zoom level on the GMSMapView?
I am using Objective-C, but if someone can only give me help in Swift or even Java I can still make do with that.

You could use a GMSGroundOverlay to add an image to the map which scales along with the map. So instead of a fixed size in pixels like a GMSMarker, it stays a fixed size in metres.
Note that another difference is that a ground overlay also stays oriented with the map, ie if the map is rotated/tilted, the top of the image rotates to point north, instead of staying pointing to the top of the screen like a marker.

Related

Mapkit - Overzoomed custom tiles not rendering when Polygons are present

I'm providing an MKMapView with an MKTileOverlay that replaces the map content. The backing tile provider only goes up to zoom level 15. If the user zooms in beyond zoom level 15 it upscales the level 15 tiles on the map instead of going blank.
However, if there is an MKPolygon or MKPolyline present in the map sector, it will only display the shape. It will no longer render the backing tile under it. This only happens when you overzoom.
I've seen some discussiong about overzooming in MapKit but they all seem to be related to versions prior to iOS 7 when a large amount of the Maps appear to have been changed.
Does anyone have experience with this?
I realized that I was completely misinterpreting the functionality that MapKit provides for Map Tiles.
When I zoomed in and saw that my Tiles were rendering I assumed it was an overzoom feature. When the areas that had Polygons were not rendering the Map Tiles as these zoom levels I thought the Polygon Renderer was somehow shutting off the tile Renderer. As it turns out, because the only active renderer at that zoomed in level was the Polygon renderer that was the only part of the canvas being redrawn, so the rest of the canvas was just still showing what it already had on there.
In laymans' terms:
The Map Tile Renderer tells the map "I can draw this large area at zoom levels 0-5." The Polygon Renderer tells the map "I can draw this small area at all zoom levels."
When I'm at zoom level 5 both the Map Tile Renderer and the Polygon Renderer kick off and draw the regions they can handle. When I move into zoom level 6 only the Polygon Renderer kicks off. The map says "I have a renderer that can draw in this region so I'm going to redraw it with that information." Because the Map Tile Renderer doesn't provide tiles for zoom level 6 it won't kick off. The rest of the map still has tiles because there is no renderer that can draw for it, so the map just keeps what it already has on the canvas.
tl;dr: I mistook MapKit not making superfluous draw calls as an overzooming feature.

How to fix various MKTileOverlay rendering problems?

I'm currently in the process of converting a custom map from using a CATiledLayer scroll view to using custom map tiles in an MKMapView with an MKTileOverlay. Whilst the CATiledLayer-approach generally works well and looks nicer, you get a lot of things for free by using an MKMapView such as rotations which are otherwise very difficult to achieve.
So, I've redrawn my tiles for use with the recommended format of zoom level, column and row numbers, and have them displaying in the map view correctly. Note that my map tiles only cover a small region somewhere; I don't have them for the entire globe.
The first problem I noticed is that there seems to be an issue when you zoom in past the largest zoom level my tiles support. I have tiles all the way to zoom level 20 so I set my MKTileOverlay's maximumZ property to 20. If you zoom in to level 21, the map view no longer requests tiles at all. Any tiles loaded on the way to level 21 still show (albeit pixelated), but if you scroll away it won't load any more tiles, so eventually the map just becomes blank. Ideally, it would fall back to my level 20 tiles and display those instead, or prevent the user from zooming in too far. When I use the CATiledLayer, you could zoom in as much as you want and it would always show the most zoomed in tiles (even if you were zoomed in further than the tiles were 'comfortable' at). Example
I have other minor niggles too:
If you set canReplaceMapContent to true, you can zoom in a lot further (which is fine), but the camera clips the ground if you get too close and I get all sorts of rendering artefacts. Any way to prevent that from happening? Example
Sometimes there are small pixel-sized rendering artefacts between tiles which indicate the tiles aren't quite positioned or sized correctly my the MKMapView. These artefacts don't seem to affect the native maps app; any way to get rid of these? Example
As you pan around when zoomed in, there are a lot of white flashes as tiles are loaded and it's quite obvious. When I used the CATiledLayer, they were loaded in quite smoothly (by animating the opacity) and the lower-zoom levels were already present in the background so it was overall difficult to tell it was even using tiles. Is there any way to load in my tiles more seamlessly? Example
I'm guessing the answer to most of these questions is that it's not possible to fix using MKMapView, which is a shame because I really want to allow the user to change the heading of the map and it seems pretty difficult to do using a standard CATiledLayer!

MapBox Marker Size on Zoom (ios sdk)

I'm trying to change the size of the marker image during a zoom event, so the image scales nicely while pinching/zooming.
I can't find anywhere how to do this, the closest I have come is to resize the marker image after the zoom event is completed (when the zoom level changes)
It would look a lot nicer if it would resize during the zoom event instead of after.
Any ideas?
Look into using RMMapLayer directly (RMMarker's superclass) which should scale when zoomed. RMShape and RMCircle are also a good, albeit not directly related, models for this since they represent shapes that "stick" to the map instead of points that don't scale. But the short answer is there is not built-in functionality for this.

Can a map overlay be moved?

I'm displaying several user's locations on a map simultaneously as circles of different colors.
I can do this using an annotation and then when the user's location updates use UIView:animateWithDuration: to move to their new location.
However there is a requirement that the size of the circles reflects the accuracy of the location i.e. very accurate equals a circle of size 10 meters, rough accuracy is represented as a circle of size 500 meters etc.
However there are two problems using annotations for this - the first is how to transform meters into a CGRect on the correct size to draw on the map. And the second is the annotations need to be resized if the user zooms the map.
So I was looking at using an overlay instead as that already has a radius and automatic resizing during zooming built in so it handles those two problems.
However it looks like overlays are meant to be static and their coordinate property is read only.
Is there some way I can make the overlays move as the user's location moves? (other than completely remove it and re-add it?)
[THis is for iOS 7 only]

iOS Maps - Grid Overlay

I'm looking for a way to overlay the iOS maps with a grid. The complete earth needs to be divided into squares. The location of the user doesn't effect the placement of the squares (In other words; the squares are always placed the same. On every iPhone, no matter where the user is).
I Looked into MKOverlay, but I've never used this so it's very new to me. Also, when zooming in/out should effect the overlay. It's very important that the squares are always covering the same area on the map (For example; A square should be 100mx100m in real world, when you zoom out, the square should cover the same 100x100).
Is there anybody that can point me in the right direction?
Is it possible to draw the grid from een .xml? Example given; On .XML is holding all squares with their coordinates on the map. When the user loads the map, the 100 squares around the user are loaded.

Resources