JSFiddle - React, Tailwind, and code Playground

by Sahil Kashyap

HTML

<button onclick="search();" name="search">search</button>
<p id="output"></p>

JavaScript

window.cb = function cb(json) {
    //do what you want with the json
    document.getElementById('output').innerHTML = json.address.road + ',' + json.address.postcode;
}

window.search = function search() {
    var s = document.createElement('script'); 
   /*  $url = "http://nominatim.openstreetmap.org/[email protected]&format=xml&lat=-23.56320001&lon=-46.66140002&zoom=27&addressdetails=1"; */
    s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat=-23.56320001&lon=-46.66140002&zoom=27&addressdetails=1';
    document.getElementsByTagName('head')[0].appendChild(s);

};