I have checked the 'Shows User Location' option of Map View in my storyboard.
I am using the simulator and do not have access to a real device. When I run the code I can see the blue icon in my map defaulted to California as you expect.
I was wondering whether this blue icon updates on a real device? Does it move when the user is moving?
Or is there additional code that must be put in to make it work?
The storyboard option correspond to the showsUserLocation property of MKMapView. From the documentation (emphasis added)
This property does not indicate whether the user’s position is actually visible on the map, only whether the map view should try to display it. Setting this property to YES causes the map view to use the Core Location framework to find the current location and try to display it on the map. As long as this property is YES, the map view continues to track the user’s location and update it periodically. The default value of this property is NO.
Of course, this assumes location services are on and the user granted the app the access to them.
Related
As can be seen in the example provided in the tutorial the Roomle configurator demonstrates different behaviors when zoomed in and a parameter is changed:
If the user clicks on the component and then scrolls to zoom in, the parameters of the component can be changed and the camera will stay in place.
If the user does not select the component first and just zooms in, the camera will reset to its original position if a parameter is changed.
I want to programmatically control camera movement and parameter selection without direct user interaction with the Roomle configurator (custom GUI) and this 2nd behavior is very annoying as the camera always jumps around.
I've tried using RoomleConfigurator._sceneHelper._cameraControl.lock() which successfully prevents manual camera movement but it will still reset on a parameter change.
How can I achieve the 1st behavior, where the camera is locked in place?
It is currently not possible to deactivate this behaviour (camera reset on parameter change).
Also a word of warning regarding the code RoomleConfigurator._sceneHelper._cameraControl.lock(). Functions which start with an underscore (_) are private and may be subject to change in a future release.
Here you can find the documentation on how to move the camera using the official API:
https://docs.roomle.com/web/guides/tutorial/configurator/07_recipes.html#move-camera
After creating a Map View in the storyboard, the default location on the simulator shows up as the United States. Looking from other SO posts, there seems not to be a way to replicate this image since we are not given the default span or region (or any way to access the user's current country and get the corresponding region and span data).
The default map view for the US looks like this:
Is there a way to copy or duplicate the initial state of the map view, so that we can restore it later?
I currently have a "reset" button, but I'm not sure what to reset to. Perhaps make the default region/span the user's current location, if there are no better solutions?
I am working on an iOS map that uses a "custom" map, stored completley in my application so it can always be accessed offline. I am using a custom MKTileOverlay URL to my local file store to make this happen, etc.
However, as my application's map only covers a small geographic area, I would like to have have the MapView display the standard Apple Map in such cases. When I overlay the map and set "canReplaceMapContent" to true, I just get a blank white space for map tiles that aren't present.
I don't really want to set canReplaceMapContent to FALSE, because most of the time a user will be using my (custom) map, so I wouldn't want the overhead of rendering the Apple map that would be completely covered.
Is there any way I can return a "nil" to a function or something to tell MapKit to not use the TileOverlay, and just use the regular Apple map instead?
No, but here's an idea: have two MKMapViews with the same frame, one with your custom map and canReplaceMapContent = YES and the other without and NO. You can hide one and show the other, transferring annotations if necessary, and you might be able to produce a convincing swap.
In my iOS app i am displaying many, big annotations, and i set user location to be shown as well. My problem is, that my markers are so big, they are covering user's position, so it's hidden very often.
My question is - is there any "normal" way to set user location's marker above all the annotations, or i have to display custom annotation for user's position, or else?
I'm building an iPhone app. There is a screen with a map (MKMapView) always showing. But to preserve battery, I don't want user location to be updated all the time, only automatically (every 15 minutes) and manually (onclick).
But, I also want to show this user location on the map.
The problem is, if I showsUserLocation for my MapView, it automatically starts updating location, hence drains battery.
I tried activating the showsUserLocation option, saving the MKUserLocation, then deactivating the showsUserLocation then adding the saved MKUserLocation as an annotation by hand, but it actually shows a WARNING and reactivate the showsUserLocation option !
So I guess the last way is by hand:
I built a blue dot annotation myself but it doesn't have the glowing effect and the accuracy circle around. Do you have any idea how to do this? Or if there is any other way, please share.
Thanks !
well you will have to go with your 'last way' -- MKAnnotationViews can easily be animated -- just treat it like any UIView :) there
see MKMapView current location showing as custom pins for how to mae custom Pins
Just use native flag to enable this like so:
[mapView setShowsUserLocation:YES]
If you want some help on the user location annotation stuff, check out how it's done in MapBox:
http://mapbox.com/mapbox-ios-sdk
In particular you want RMUserLocation. The whole SDK is open source.