Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SKMaps showing multiple Maps

I want to show two maps in my app. One big map in a view and another one in a other view as a "mini map". The mini map should be static.

My problem is, when I'm on the big map and scroll over this map and go back to the other view where the mini map is, the coordinates of the mini maps becomes the same as it is on the big map.

BIG MAP CODE:

self.placeMapView = [[SKMapView alloc] init];
self.placeMapView.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame));
self.placeMapView.delegate = self;
self.placeMapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.placeMapView.settings.poiDisplayingOption = SKPOIDisplayingOptionNone;
[self.view addSubview:self.placeMapView];



//set the map region
SKCoordinateRegion region;
region.center = CLLocationCoordinate2DMake(40.758637, -73.986171);
region.zoomLevel = 17;
self.placeMapView.visibleRegion = region;

MINI MAP CODE:

self.miniMap = [[SKMapView alloc] init];
self.miniMap.frame = CGRectMake(0.0f, 0.0f, CGRectGetWidth(self.showMap.frame), CGRectGetHeight(self.showMap.frame));
self.miniMap.delegate = self;
self.miniMap.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.miniMap.mapScaleView.hidden = YES;
self.miniMap.settings.showCompass = NO;
[self.showMap setUserInteractionEnabled:NO];
[self.showMap addSubview:self.miniMap];


//set the map region
SKCoordinateRegion region;
region.center = CLLocationCoordinate2DMake(40.758637, -73.986171);
region.zoomLevel = 15;
self.miniMap.visibleRegion = region;

These snippets are not in the same View and not in the same Code!

How can I prevent this behaviour?

EDIT: Ok that was easy. Don't know why it takes so much time till I get it. Just execute the Code/Function in the viewWillAppear Method. So it's solved!

like image 858
TdoubleG Avatar asked Mar 16 '26 12:03

TdoubleG


1 Answers

EDIT: Ok that was easy. Don't know why it takes so much time till I get it. Just execute the Code/Function in the viewWillAppear Method. So it's solved!

This is not solved, you just hide the problem by resetting coordinates of the map you want to display before it appears.

I have the same issue with Android+iOS SDk 2.2.0, so I'm temporally keeping a trace of current position to restore it later as you're doing, but if someone knows how to solve this, that'd be good, because it doesn't seem normal to me that 2 different instances shares properties

Btw, only properties about map rendering seems to be shared, as disabling pinch / pan / rotate on a map doesn't change those properties on the other. The strange part is that each instance of SKMapSurfaceView instantiate its own rendering object, as seen on Skobbler's source code:

...
this.a = new MapRenderer();
...
like image 118
Thibaud David Avatar answered Mar 18 '26 02:03

Thibaud David