MapKit uber style map Center annotation - ios

I would like to have a annotation in the center of the map, that does not move when the region is changed. That is, when one moves the map, the annotation stays in the center regardless. I have implemented this using NStimer, assigning the map center coordinate to the annotation every .001 seconds, however this is very choppy and doesn't look smooth.
I realize that I need to use an Overlay than convert the overlay annotation to coordinates on the map.
Pretty much it would look like what Uber has.

THe other solutions for this that I have seen have not used a normal annotation. Instead they put another view over the top of the map with the annotation image in the middle. It doesn't matter what happens to the map the view stays centered on the screen and if you do ever need to interact with it, you just ask the map what the center coordinate is at that time.

You can get the code from the following link:
https://github.com/scottrhoyt/CenterPinMapViewController

Related

Prevent GMSMarkers from Scaling on 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.

MapKit MKCircle Change Radius on Zoom Level

I'm trying to create an MKCircle overlay on a map, however I would like the size of the circle on the screen to remain constant as the user zooms.
So as the user zooms in, the radius gets smaller and as the user zooms out, the radius gets larger.
I'm working in Swift 3. Is there a specific MapKit method I should be using to accomplish this? I know there is an option to use an image of a circle as an annotation, however I want to dynamically change the color of the circle.
In other words, I want the MKCircle to scale the same way an MKPolyline scales as you zoom in and out
So as the user zooms in, the radius gets smaller and as the user zooms out, the radius gets larger
An MKCircle would presumably be part of an overlay (MKOverlay). An overlay works by simulating drawing on the earth itself. Thus, the drawing changes with the zoom level.
So if you don't want that to happen, don't use an MKOverlay. You could, for example, just make a normal view that displays a circle and lay it in front of the map view. Or you could use an annotation instead (MKAnnotation); an annotation's image does not change size as the map is zoomed.

How to fix popup position?

In this example how to fix popup position when I zoom ?
Popup example
The popup (an ol.Overlay) is already fixed to a given coordinate, the one you click. When zoomed, the visual distance between the popup and the marker changes but they are still at their given coordinates.
If you don't want two objects to move apart when zoomed in, make sure that they are positioned on the same coordinates.
You can set the clicked features coordinates as the overlay coordinates, and still show it X number of pixels above the point by using the offset option on the overlay.

Drawing World Map - Performance & Interaction - iOS

I’d like to use a Shapefile to generate an interactive world map. I was able to import the data and use CG Paths to draw the map into one large view.
The map needs to support panning, zooming and touch interaction. For that, I've created a UIScrollView and placed the MapView (large view with all of the countries drawn) into it.
I need to improve two aspects of it:
Performance / rendering
I have drawn the map much larger than the screen size, in order to make it look reasonable when I zoom in. There are a few problems with this. First, when I'm zoomed out, I need the border stroke/line to be wider so they are visible. When I zoom in, I'd like the stroke to be a thinner. Also, when I zoom in, I can still see that the map is a blurry. I don't want to increase the view size too much.
How can I make the map look crisp when I'm zoomed in? I attempted to redraw the map on zoom in, but it takes far too long. Can I somehow only re render onscreen stuff?
Touch Interaction
I need to be able to have a touch event for every different country.
Possible approach?
I was thinking of trying to separate every country onto it’s own view. That should make touches easy to handle. Then I’m thinking I can possibly redraw the appropriate views that are on screen/zoomed to.
I've played with an app that does something similar ("World Maps"), and I can see that when you pan or zoom, the map is blurry for a second but then becomes clear. What is going on there?
use mapkit and provide custom tiles. dont reinvent the wheel and try to write yet another map framework
I think that you have to create different scaled area image from the big map image. how to say... imagine the google map, how it works... I think that provide many different zoom factor image for every area of the world... then merged display on the screen while user need show it ...
use code implemented the map effect is impossible on current iPhone device, out of the ability of the iOS device

Adjust MkMapView Annotation

I'm adding annotations to an MkMapView and am using a custom image to do so. My custom image is box shaped with a little triangular arrow that's supposed to be right on the place that's being annotated. It seems like MapView by default annotates using the geometric center of the image. What's the best way to design around this problem? Manually moving the icon? Creating the icon in a specific way?
Here's the Apple docs for MKAnnotationView's centerOffset property:
By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in pixels. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.

Resources