Whatever I try I cannot get a basemap to show with a Mobile Map Package. I would rather show a local vtpk instead of an esri online basemap. Here is my code:
Item {
anchors.fill: parent
signal openMenu()
property string searchPane: ""
property string inputdata: "ZooScapeMKE.mmpk"
property string locatorFileName: "Locator-MKE.loc"
property string filePath: "../data/"
MapView {
id: mapView
anchors.fill: parent
focus: true
}
MobileMapPackage {
id: mmpk
path: filePath + inputdata
Component.onCompleted: {
mmpk.load();
}
onLoadStatusChanged: {
if (loadStatus === Enums.LoadStatusLoaded) {
mapView.map = mmpk.maps[0];
console.log(mapView.map.spatialReference.wkid);
mapView.map.minScale = 15000;
mapView.map.maxScale = 1000;
var basemapLayer = ArcGISRuntimeEnvironment.createObject("ArcGISVectorTiledLayer", {url: filePath + "BasemapGrayMKE.vtpk"});
mapView.map.basemap.baseLayers.append(basemapLayer);
}
}
}
}
Solved! Go to Solution.
Tim,
I shared a modified version of it back into the group (lightgraybase). In the resources folder I just swapped the root.json folder in the styles folder and the content in the Sprites folder (from the resources.zip that I referenced earlier) and re-zipped the .vtpk.
If you share your broken one, I might be able to see what is wrong with it.
Mark
Tim,
I don't have an answer for you, but curious about what you are trying to accomplish.
You could include the .VTPK as a basemap in the MMPK.
Mark
I agree with Mark - the best solution is to author your map with the vtpk directly in it.
If you can't do it, I think the issue might be with your URL property of the vector tile layer object - URL properties will take either an online or local file url, so for example, could start with "http://" or "file://". Path properties are for local files only (hence why your mmpk path can use your filePath relative directory variable).
Thank you both for the reply. I have tried that but the issue is my data is in a different coordinate system (wkid 4326) than the basemap (wkid 3857). I can't create a mmpk if those are not the same. If I change the data frames coordinate system and/or project the data to 3857 then it warps the data and does not fit the basemap. I'm pretty sure I cannot change the coordinate system of the vtpk file.
I decided to just live with the skewed data as it will not work any other way. I now have run into another problem. The .vtpk displays as a light gray basemap in ArcGIS Pro but when I create a mmpk and display that on my mobile device the basemap shows as an entirely different basemap. See below
The comments in these resources explain what is happening.
The Esri basemaps have an external style file that "tells" the vector tiles how to display. There is also an internal style with the tiles. When you use ArcGIS Pro to download the .vtpk, you do not have access to the external style. The second link above explains how to manually replace the internal style.
Hi Mark,
I noticed on that 2nd link that the styles should be included with ArcGIS Pro 2.5 which to me means that we don't have to do this workaround? I am using version 2.5 and the styles are not working
The VTPK will only show the correct styling within a mobile map package. When you download the map in Pro a layer is added to the map. If you package that layer in a mobile map package, it will display correctly in Runtime 100.7 and later. If you want to use the .vtpk file that Pro writes to disk, you will need to update the internal files.
Tim,
Here are the style resources for light gray basemap - http://www.arcgis.com/home/search.html?q=id%3A4ce44222d02d4a91b1f7308f855514da
Unzip your VTPK file. In the resources file replace the content in the info, sprites and styles folders with the content in the item linked to above.
Then re-zip to use your vtpk as a light gray basemap.
Mark
Thank you for your quick replies. I did as you said but when I add to ArcGIS Pro this is what shows (there is no spatial reference)
Do I need to change anything in the json files of the three directories before I zip it back up?