Skip to content

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

License

Notifications You must be signed in to change notification settings

Logic-gate/What3words-map-marker

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published