offline map do. not load when we go offline on mobile or laptp

723
3
01-20-2021 11:20 PM
rsharma
Occasional Contributor III

hi

my offline map do not load when i go offline on windows and mobile android  and iphone. it only work on mac and only the part which is zoomed get accessed after it goes offline

 

 property string assetsPath: "../../../assets/"
    property string mapPackageFileName: "new_topoNZ_map.mmpk"
    MobileMapPackage {
         id: mmpk
         path: assetsPath + mapPackageFileName
         onLoadStatusChanged: {
                if (loadStatus !== Enums.LoadStatusLoaded) {
                    return;
                }
                if (mmpk.maps.length < 1) {
                    return;
                }
                  mapView.map = mmpk.maps[0];
                  mapView.map.initialViewpoint = viewpoint;
            }
            onErrorChanged: {
          console.log("Mobile Map Package Error: %1 %2".arg(error.message).arg(error.additionalMessage));
            }
     }
 // *** declare mapview***//
    MapView {
        id:mapView
        property real initialMapRotation: 0
        Component.onCompleted: {
                mmpk.load();

            }
        anchors {
            left: parent.left
            right: parent.right
            top: parent.top
            bottom: parent.bottom
        }

    }//End Mapview

 

0 Kudos
3 Replies
PaulHaakma_Eagle
Esri Contributor

Is it possibly related to how you are referencing the path to the mmpk? You are referencing a relative path using "../.." which iOS and Android might not like.

Or, even if that relative path does work, iOS and Android might not be allowing opening/accessing the files in that particular location (which could involve spinning up temp files etc).

I suggest taking a look at the "Open Mobile Map (mmpk)" app sample from the AppStudio team which shows how an mmpk bundled with an app can be then copied across to a user folder and accessed from there. Lines 42 through 51 in the main MyApp.qml file show the data paths and function for copying the data.

Hope this helps, if not then please post more info.

0 Kudos
rsharma
Occasional Contributor III

hi @PaulHaakma_Eagle 

i agree with your point for refrencing issue.

 Now It works on mac and iphone but do not work on android and window in offline mode.

No error occur, file path consoled is also ok. Don't know what is the problem.

i tried that sample also in my code. then same problem persist.

Then i replace my mmpk file in that sample. on android phone, it doesn't work on android but work on iphone.

 

Is their any option to create mmpk for both ios and android??

0 Kudos
PaulHaakma_Eagle
Esri Contributor

Off the top of my head I can think of four things it could be...

Something to do with online/offline, although I can't see how that would make any difference accessing a local mmpk file. If it works online but not offline, possibly there is something else breaking the workflow completely unrelated to this part of your code?

Something to do with the file path to the mmpk - in which case the AppStudio team's sample would be helpful (as per previous post).

Something to do with the mmpk itself - but if it loads in some situations this would suggest the mmpk is ok. You could test further by swapping out your mmpk for the one from the AppStudio sample to see if that one loads, and vice-versa you could drop your mmpk in place into the AppStudio sample.

Or build settings - check are "External Storage" and "File Sharing" turned on? If not, try turning them on just to see if that makes a difference.

 

Another way to troubleshoot, does the "Open MMPK" sample work on your devices from within the AppPlayer? If so, does your app work when run from within AppPlayer?

Beyond this, might be hard to troubleshoot without seeing the full code. If sharing the code is a possibility then I'm happy to take a quick look, otherwise you might need to reach out through your normal ESRI support channel to get some specific help.

 

0 Kudos