Moving Map Under the Marker in Mapbox iOS SDK - ios

I am new in MapBox iOS SDK and I need to add a marker in the center of MGLMapView so that user would be able to move map view under the marker and the marker would be fix on the screen. I also need to get the coordinate of the point in the map that is under the marker. I could not find any method in Mapbox SDK and I have no idea how to do that.

I believe this is quite easy. Add an image of a marker on top of the map to give the visual effect so the user can still scroll around without moving the marker. Then you can get the center coordinates usually quite easily using mapView.centerCoordinate when the user stops scrolling.
Here is the API documentation link for reference

I had done something like this in one of my apps
1) Add map to UIViewController
2) Add a Transparent view on top of the map in UIViewController. (May need to set userInteractionEnabled to false. Not sure though!)
3) Add marker image to the Transparent view so that its bottom tip is at the center of the view it is added to.
4) Get center coordinates by using mapView.centerCoordinate

For other people who have this issue too:
let markerImageView = UIImageView(image: UIImage(named: "Orange"))
markerImageView.center = mapView.center
mapView.addSubview(markerImageView)

Related

MKAnnotation is not moving with map after update the position

On first time load, it's working fine and move along with MapView, but if I change the marker position and then if I drag the map view that marker is not moving with map.it's just stuck on that place. It's only happening in iOS 11 or below that version.
See the  screenshot its just stuck  that place.moving mapview.
I don't know that this will work, but you can change coordinate of annoation use
[yourAnnotation setCoordinate:newCoordinate];
Pls see if this SO question helps you MKMapView moving Annotations Automatically - animate them ?

How to keep an MKAnnotation View Image fixed on the center of the map as the user pans and moves the map around (Swift)?

using target 8.0 MapKit, I would like to define an MKAnnotation (such as a pin, or a custom one) that remains fixed on the center of the map view as the user moves the map around. Once the user stops moving the map, I would like to be able to read the new coordinates of the annotation. How can I do this? This in swift, thank you soo much
You can follow this link to accomplish this task.They are doing something very similar to your requirement. Its quite descriptive. Link

Google Maps IOS SDK - Refreshing the MapView. (Objective-c)

I made a settings tab for the MapView's ViewController and it works fine when I open the MapViews's VC the first time. but when I change the settings after I opened and loaded the mapView the first time the settings that I changed don't apply to the mapView because it did not refresh. Is there a way of refreshing the data of the mapView? I have searched everywhere and couldn't find an answer.
if this question have been answerd before can you link me to it? Thank you.
I'm using the GoogleMaps ios sdk.
and I'm using obj-c.
If your settings just changes the icons, annotations, map markers or layers color , or location of markers or layer, the simplest way to do is clear all the markers and layers you add on the map view and re-add them. For example, implement a refreshMapView method
-(void)refreshMapView
{
[mapView clear];//this line clears all the markers or layers you drew on the mapView.
// then implement your method to re-draw the markers and layers, or load new settings.
// for example, go through your marker list, and add them as follows:
for (id yourobject in yourMarkerArray){
GMSMarker *marker = [GMSMarker markerWithPosition:coordinatesOfMarker];
//custom marker here, set title, or snippets, or icon, etc...
marker.map = mapView;
}
// you can also redraw any map overlay here...
}
Jing's answer to implement a refreshMapView method is good, you could call that in your map view controller's viewWillAppear section.
Make sure you're actually setting the mapView properties in the same scope — i.e., your settings view and your map view may be looking at a different object or changes may be getting discarded. Without seeing the code for how you're trying to modify those settings, it's difficult to say.

How to fix the annotation image on map view?

I am working on app which will show the current user location on map.I am using the custom annotation on map view for example a car image.I am rotating this image by finding the angle between two locations.But whenever user rotates the map view my annotation also rotates which is for obvious reason and my image moves in wrong direction.In android we can set flat property to true so whenever user will rotate the map the annotation image will also rotate along with it.
Please suggest something useful.Thank you.

snapshot/screenshot with MKMapview

I am trying to make a snapshot from a view with a MKMapview to provide a springboard like folder animation when the user selects an annotation.
The official way to make a snapshot of the current window is presented here. This works fine (though quite slow) unless the mapview is not zoomed in too much and has a "regionThatFits" set. The map & the marker make an unmatched "jump" to the left and the gridlines of the mapview are visible:
Before screenshot:
After screenshot:
I suppose it has something to do with the tiled parts of the map but I don't know how to prevent that behaviour.
Any thoughts?

Resources