It turned out to be a non-trivial task and I needed to make a few changes to the official API distribution to get the sample working.
Most of the problems were related to the URL scheme/protocol ms-appx-web: used by Windows Store applications’ WebViews.
Let’s start with the installation.
According to the official install.htm one should replace
That was not working for me at the first attempt so I decided to modify the entire baseUrl property.
baseUrl:(location.protocol === 'file:' ? 'http:' : location.protocol) + '//' + "[HOSTNAME_AND_PATH_TO_JSAPI]dojo"
I’ve used the same trick also with the API version 3.14 a few months ago.
After I got the baseUrl property right the API started to load but it failed to get the basemap. The exception I was getting was “The system cannot locate the resource specified.” The problem was that the API was trying to get the basemap from an invalid URL
I managed to trace this problem back to a getabsoluteurl(a) method in init.js file.
It is incorrectly determining the URL scheme. It recognizes http and https only.
I fixed my problem my replacing a regular expression
This changed moved me one step further to another exception. This time it was complaining about
See that it’s again using the ms-appx-web scheme instead of http. I couldn’t find the place where this URL is being built.
I helped myself by prepending
For some reason I had to do the same trick for
Finally it all started to work and the basemap loaded and displayed correctly.
I know that my changes are not the best ones. I made just to move forward to get the sample running. They are not complex and I do not know what side effects they might have that I’ll run into later when I’ll start migrating our existing Windows Store application built with API 3.14.
It would help me a lot if there was an official support for this type of deployment in the future API 4 releases.