A simple "responsive" JS script that integrates what3words into a GoogleMaps canvas
JavaScript HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
demo.html
what3words-map-marker.js
what3words.js
what3words_logo_final.png

README.md

what3words-map-marker

A simple "responsive" JS script that integrates what3words into a GoogleMaps canvas

The script aims to aid those who wish to integrate what3words into their existing projects by providing a marker based selection process; move the marker, get the three words. It uses the default what3word-js-wrapper.

Instructions on getting the demo to work

  • Make sure you add your own API key in what3words.js
  • Make sure you add your own GoogleMaps key in line 45 on demo.html

If you are wondering how to catch the three words, as to pass it along or to store it; you can do so by capturing ret in the what3WordsConvert function from what3words-map-marker.js.

Example:

var what3WordsConvert = function(lat, lng) {
    what3words.positionToWords([lat, lng], function (ret) {
        document.getElementById('current').innerHTML = '<p>'+ ret.join('.') +'</p>';
        alert(ret); //This will create a popup with the selected three words
        document.getElementById('three-word').value  = ret.join('.');
    });
  }

Please note, demo.html is just a demo. You will need to write up your own handlers in what3words-map-marker.js for passing the three words.

For more information about the what3words' api, head over to http://developer.what3words.com/api

Screenshot

Screenshot of demo.html demo.html

Screenshot from Rukny rukny demo