Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The MazeMap webview allows you to send in custom location updates, allowing you to define where the blue dot should be shown.

This is done by performing a Javascript command in the MazeMap webview.




HTML Comment

Denne synes ikke på den faktiske siden.


Her er linken til draw.io-diagrammet over:


https://drive.google.com/drive/folders/0B7uv_DvQTZFLTmFJQ1k4c01TdVk?usp=sharing



Performing JavaScript commands in a webview

 In Android, use WebView.postWebMessage to send the message. If you must support an older Android SDK which does not implement postWebMessage, you can alternatively use evaluateJavascript(), e.g.:


Code Block
String js = "var msg={ ... }; window.postMessage(msg,'*');"; webview.evaluateJavascript(js);


In a similar fashion, evaluateJavaScript() can be used in iOS:

Code Block
String js = "var msg={ ... }; window.postMessage(msg,'*');"; wkwebview.evaluateJavaScript(js);



The Javascript Command


Code Block
var msg = {
    type: 'MM_INJECTABLE_LOCATION_UPDATE',
    data: {
        latlng: {
            lat: 63,
            lng: 10.5
        },
        accuracy: 500,    // In meters
        mm_z: 3,    // Optional numerical z-level
    }
};
window.postMessage(
    msg,
    '*'    // The "origin" of the destination window, which can be
        // replaced by the domain name of the currently loaded webpage.
);


Coordinates

The coordinates must be WGS84 latitude and longitude values.

If you are using a third party location source/SDK that provides coordinates in another format, you will need to convert them before sending them to into the MazeMap web view


Z Level (mm_z)

Z level is a MazeMap-proprietary value that defines floors/altitude.

Third party location providers will likely use their own proprietary floor level or floor ID values.

You may need to create and maintain a mapping between MazeMaps z-levels and the third party providers floor IDs.