Load local vector pack

698
2
05-10-2017 06:03 AM
Armandvan_der_Zwan
New Contributor II

How do I load a vtpk file as a base map?

When I do it like this, the App loads the whole vector map in to memory -> crash !

self.vectorTiledLayer = [[AGSArcGISVectorTiledLayer alloc] initWithName:@"..."];
[self.vectorTiledLayer loadWithCompletion:^(NSError * _Nullable error) {
                if (error){
                    NSLog(@"Error: %@", error);
                }
                weakSelf.arcGISMap.map =  [AGSMap mapWithBasemap:[[AGSBasemap alloc] initWithBaseLayer: self.vectorTiledLayer]];
            }];
0 Kudos
2 Replies
DiveshGoyal
Esri Regular Contributor

Can you provide the stack trace you get when the app crashes?

Also, does the crash happen when you create the instance of the layer, or when you add it to map as a base layer?

Just to clarify, we don't load the whole vector tile package into memory, we access individual tiles that are needed from the package on disk.

0 Kudos
Armandvan_der_Zwan
New Contributor II

For now it is no longer crashing, but I do see a huge memory peak to 400 - 600 MB after loadWithCompletion.

The test file I'm trying to load is:

http://www.arcgis.com/home/item.html?id=b84c4ec081b740f9ba299f04fbcae300

Maybe there's something wrong with it.

When loaded, there is no map, and I cannot zoom or pan.

Doing it like this now:

...
AGSBasemap *baseMap;
if (loadLocalMap) {
   AGSArcGISVectorTiledLayer *baseLayer = [AGSArcGISVectorTiledLayer ArcGISVectorTiledLayerWithName:@"nederland"];
   baseMap = [AGSBasemap basemapWithBaseLayer:baseLayer];
} else {
   baseMap = [AGSBasemap streetsVectorBasemap];
}
self.map = [AGSMap mapWithBasemap:baseMap];
[self.map loadWithCompletion:^(NSError * _Nullable error) {
   if (error){
      DDLogWarn(@"Error: %@", error);
   }
   weakSelf.arcGISMap.map = weakSelf.map;
}];
0 Kudos