Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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 sending performing a Javascript command in the MazeMap webview.


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.:


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


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

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



The JavaScript command

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.
);


  • No labels