Overview
The location question of SurveyToGo can work in two formats, online and offline. When used in online mode the location question will use Google maps as a mapping engine. You can read more about how to use the online mapping mode of the location question here. In some cases where network connection is not available you might prefer to use the offline mode of the location question. While it requires more work to set the offline mode up it will provide you with the ability to have a full location question up and running while being completely offline. The mapping format used will be 'Osmdroid SQlite'. There are various tools that allow you to create such file formats. One example is the open source Mobile Atlas Creator.
To create the map with Mobile Atlas Creator and use is as offline maps:
- Step 1: Install Mobile Atlas Creator
- Step 2: Create the offline map file for the relevant area
- Step 3: Load the map to the SurveyToGo survey and configure the location question to use that file as a map source.
- Step 4: Optionally controlling the start position of the map and zoom level
- Step 5: Showing the map on the tablet
Step 1: Install Mobile Atlas Creator
If you do not have the “Mobile Atlas Creator” app installed on your PC, please first install it by following these steps:
- Install Mobile Atlas Creator. You can find it here Mobile Atlas Creator
- Then extract the file to your preferred location on your hard drive and start the app by double clicking on “Mobile Atlas Creator.exe
Step 2: Create the offline map file for the relevant area
To create the offline map of your choice, please make sure you have the Mobile Atlas Creator app installed and launched. If you do not have it ready, please refer to the previous step in order to download & install the app. To create the offline map, please follow these steps:
- Launch Mobile Atlas Creator
- Go tot he Atlas Menu and select New Atlas with the Osmdroid SQlite format you want the maps to be generated in:
- Choose one of the sources from the list for example OpenStreetMap Public Transport:
- Now, zoom into the relevant area you wish to create a map for. You can use the right mouse button to move around the map and the mouse-wheel to zoom in and out. Once you are around the required area, use the left mouse-button to mark a selection and then click the “Add selection” button to add this selection to the atlas. (Please read the next step about zoom levels before adding the selection):
- Please pay close attention to the “Zoom Level” boxes that are ticked:
The higher the zoom level that is ticked the more details the offline map will include but in turn the bigger the file that will be generated. In any case do not check zoom level 18 as it will create a huge file and level 17 already includes individual street level maps. We recommend checking up to zoom-level 16 for areas which are bigger than regular cities and 15 for areas as big as a country.
Important Note:
If a 17 zoom-level is chosen for a big area the resulting offline map file will be huge and probably will not be able to run on the device. Please only choose zoom level 17 in case you need the individual street level maps. Zoom level 16 will have street level information as well but some smaller streets will not display.In case you wish to see the relevant zoom level, you can always see it on the map itself so that you can decide if you can do with a certain zoom level:
- If you added the selection and ticked an inappropriate zoom level, you can always change it by right clicking on the “Layer” you added and selecting “Delete”:
Then, you can check/uncheck the relevant zoom level and click on “Add selection” again:
- Once everything is set correctly you are now ready to create the offline maps file. To do this, click the “Create Atlas” button:
- The app will start generating the offline maps file and you will see the progress of the file creations. The creation process might take some time as the maps will be downloaded from the internet:
- Once it completes, click on the “Open Atlas Folder” button to get to the file that was created:
- You will see a folder was created with the date and time of today, and inside the folder there is a file with extension “.sqlite”. This is the file you need to use in the next part of the guide:
You can rename this file to any file name you wish to be more descriptive.
- If you need to generate a new offline maps file you can repeat the steps in this part of the guide. Just make sure to always take the file from the most recently created folder.
Step 3: Load the map to the SurveyToGo survey and configure the location question to use that file as a map source
Once you created the “Layer.sqlite” file (you can rename it to any file name you wish) you are now ready to use this file from within the SurveyToGo location question. There are 2 ways of using this file:
- Copy the file to the devices by yourself, then point the map question to use the already existing file.
- Attach the file as a survey attachments, then point the map question to use the survey attachment.
There are pros and cons to each approach, but our guideline is to use option #1 for any SQLite file bigger than 15MBs:
Approach | Pros | Cons |
Option 1: Copy the “Sqllite” file to the devices by yourself |
|
|
Option 2: Attach the “SQLite” file as a survey attachment |
|
|
We will now show you how to use each approach.
Option 1: Copy the “Sqllite” file to the devices by yourself
In this approach you simply copy the file to the device and not the name of the file. Then, in the survey do the following steps:
- Add a location question, then in the answers check the “Use offline mode”:
2. Next, switch the offline maps source and select “New”:
3. Now you’ll need to add a new attachment source by clicking on the “+” sign, and entering the path to the file that you copied to the device. The script to use is in the form of: list.Add("$ROOT$/Layer.sqlite","1"); , lastly you need to give this attachment source a name and click on OK to approve:
4. Finally, select the new Attachment Source name you just created from the list:
Option 2:
In this approach you first attach the sqlite file to the survey and then configure the survey to use the attachment. Here is how to do it:
- Click the main survey and then select the “Advanced tab”, and click on the “Edit Survey Attachments” link:
2. Click the “New” button to add a new attachment:
3. Click the “Add files” button and locate the sqlite file. Then click on open to add it to the list of files to upload:
4. To complete the upload click the “Upload” button:
5. Once the upload complete you will be able to use this uploaded file when configuring the location question.
6. First, add a location question, then in the answers check the “Use offline mode”:
7. Next, switch the offline maps source and select “New”:
Important note:
This step is slightly different than in the other option, please note the change in the script syntax and do not use the script from the previous approach.
Now you’ll need to add a new attachment source by clicking on the “+” sign, and entering the name of the attachment. The script to use is in the form of: list.AddFromAttachment("Layer.sqlite"); lastly you need to give this attachment source a name and click on OK to approve:
8. Finally, select the new Attachment Source name you just created from the list:
Step 4: Optionally controlling the start position of the map and zoom level
If you wish you can control the start position of the map and the zoom level so that the map is centered correctly when starting the map. To do this, follow these steps:
- Switch to the “Scripts” tab of the question and click on the “Advanced scripts” link. This will open up the global function library of this survey:
2. Now, add the following function to the script library:
Here is the code:
function OnMapShowing(inCallback, inQuestionIndex, inIteration){ inCallback.setMapCenter(CreateCoords(51.522202,-0.147206));
inCallback.setZoomLevel(13);
inCallback.setSatellite(false);
}
You can of course change the coordinates to the coordinates you wish to center the map on. This function will be called each time the map will show and it will make sure to center the map to the relevant coordinates and also set the zoom level to 13.
Step 5: Showing the map on the tablet
Once everything is configured correctly and after the survey is synchronized to the tablet the location question will show on the tablet:
Clicking on the “Open Map” button will open the map and center it correctly, then allow you to pin the location to where you wish and also play with the zoom level:
Then lat/long of the pinned location will be captured once the OK button is pressed:
That’s it!
Visit us at: http://www.dooblo.net
Comments
Please sign in to leave a comment.