Navigate a route without following it in the SKMapView - ios

SKMaps is an excellent framework for a lot of mapping uses. I have a bit of a unique requirement and I'm hoping someone might have a solution. I'm curious if I can calculate a route, paint that route on the map, and then start navigation without having the map adopt the follow-the-driver UI. I want to be able to continue some basic interaction with the map (including animating different points to the center, etc) while navigation is in-progress.
My ViewController is both the routing delegate and the navigation delegate of the SKRoutingService shared instance. I did attempt to set the routing service's mapView pointer to nil when the route gets calculated, right before I start navigation, but to no success -- the mapView still zooms into the current location, the current position icon changes to the navigation one, and the map starts following the driver.
Any ideas?

Set the following after starting navigation:
[[SKRoutingService sharedInstance]startNavigationWithSettings:navSettings];
self.mapView.settings.followUserPosition = NO;
self.mapView.settings.headingMode = SKHeadingModeNone;
self.mapView.settings.displayMode = SKMapDisplayMode2D;
SKCoordinateRegion region;
region.center = CLLocationCoordinate2DMake(37.9667, 23.7167);
region.zoomLevel = 17;
self.mapView.visibleRegion = region;
This would start the navigation but not change the view (the user position will still change on the map, reflecting the change in position)

Related

Not able to move map after starting navigation

hi i am using skobbler offline map in my application and everything works fine except one thing, after starting navigation i am able to rotate, zoom in, zoom out in the map but cannot move the map please help solving this. if i set follow user position to NO it works fine but i have to follow user position while in navigation. i had already tried this
Not able to move map after starting Navigation SKMAPS but i want follow user position to be YES .please help thanks in advance
[SKRoutingService sharedInstance].navigationDelegate = self;
SKNavigationSettings* navSettings = [SKNavigationSettings navigationSettings];
navSettings.navigationType=SKNavigationTypeReal;
navSettings.distanceFormat=SKDistanceFormatMilesFeet;
[[SKRoutingService sharedInstance]startNavigationWithSettings:navSettings];
self.mapView.settings.followUserPosition = YES;
self.mapView.settings.displayMode = SKMapDisplayMode2D;
I think that these 2 requirements are conflicting:
you want to be able to pan the map - this means that you should be able to move where ever you want on the map disregarding the current user position
you want to follow the user position - this means that the map should automatically recenter on the user every time the user position is updated
From my view you can switch between these 2 scenarios (see for example the "Car navigation UI" example in the skobbler/Telenav demo project - there once you start panning the map you go to 2D without following the user position and when you click the "back" button you switch back to 3D navigation following the user position) but you can't have both at the same time (as they are logically exclusive).
If I'm missing a specific use case let me know

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.

GMSPanoramaView - change the location point and the camera fields at the same time

I'm having in my app a GMSPanoramaView witch contains some street view images.
I want to change those images to several locations with different 'heading' - directions.
I can't see a way to update the view with the new location, and the new heading at the same time.
The only way I can see is updating the location (by moveNearCoordinate func)
and only after the camera's heading (by updateCamera: func).
But this way cause a 'jump' in the seeing image -
the view presenting the new location, and than jumping to the wanted heading.
(the same will happens if i will update the camera first, and than the location).
I want the view to present the new location with specific direction Immediately.
I will be happy for some solution.
thanx.
You should make your heading changes in this method given to you by the GMSPanoramaViewDelegate
- (void)panoramaView:(GMSPanoramaView *)view
didMoveToPanorama:(GMSPanorama *)panorama
nearCoordinate:(CLLocationCoordinate2D)coordinate
In this method, you should only call self.view = self.panoramaView; after you've changed the heading by updating the camera. This is how I fixed a similar issue I was facing with the setting the heading of the panoramaView.
func panoramaViewDidFinishRendering(_ panoramaView: GMSPanoramaView) {
if (flag_init){
flag_init = NO
panoramaView.camera = GMSPanoramaCamera(heading: 180, pitch: 1, zoom: 1)
panoramaView.alpha = 1
}
}
i can't find how can do it but can minimize the time , of course you can modify the code to make sure the alpha value become 1 for second finish rendering

Bring ios mapview in zoomed in mode during first load

Hello i am doing an iOS6 in-house iPad app. On my ViewController i have a scroll view. On that at the bottom left i have a map view (20,594,360,347).Mapview location on my scroll view. I have a get location button. Brings the location correctly in zoomed in mode (it shows my office on the map clearly).Works fine. I save the record and open another one and save this record also. So i have 2 records now. Here is my problem. I open my first record and it brings the map in world view. I can see the annotation of where my office is and i zoom in... zoom in and i see my office. It doesnt bring the location directly in zoom in mode. I close this 1st record and open 2nd record it brings in the location in zoomed in mode(can see my office). I open first record now, i get zoomed in mode (i can see my office clearly). So how do i get the map view to show my first record the first time in zoomed in mode?
Summary : Opening a saved record for the first time shows the map in world view as against to zoomed in mode.
- (void)setMap:(CLLocationCoordinate2D)currentCoordinates{
....code
[self.nwMapView setMapType:MKMapTypeSatellite];
[self.nwMapView setScrollEnabled:YES];
MKCoordinateRegion extentsRegion = MKCoordinateRegionMakeWithDistance(currentCoordinates, 80, 80);
extentsRegion.span.longitudeDelta = 0.002f;
extentsRegion.span.latitudeDelta = 0.002f;
[self.nwMapView setRegion:extentsRegion animated:NO];
ITMAnnotation *annotation = [[ITMAnnotation alloc] initWithCoordinate:currentCoordinates addressDictionary:nil];
annotation.title = #"Drag to Move Pin";
annotation.subtitle = [NSString stringWithFormat:#"%f %f", annotation.coordinate.latitude, annotation.coordinate.longitude];
NSLog(#"subtitle change at 314");
[self.nwMapView addAnnotation:annotation];
self.tempMapView = self.nwMapView;
}
What setting should i enable to get the map in zoomed in mode.? If you need more information,please ask. Thanks.
At what point are you calling setMap? If you are doing it before viewDidLoad then you'll be losing all the set up you do to the UI because it hasn't been loaded yet. Once the VC is loaded you can setRegion on the map and do what ever. I suspect you are reusing the VC with the second record so it is calling setRegion on map that is read to be used.

Problems with current location pin

I'm working on an app that shows a couple of places on the map along with the user's current position.
I have two small problems with it:
First off, I want the current location pin to be the default blue circle, but it shows a green pin just like the other locations.
Second problem, whenever I touch the screen, the current location pin drops again. It just can't seem to be steady like the other ones. It's like it's being called whenever I interact with the app.
Make sure you set your mapView delegate to self...that should fix the pin color. Not sure about your other problem
// in the viewDidLoad
[mapView setDelegate:self];
where "mapView" is defined as "IBOutlet MKMapView *mapView;"

Resources