2

I am able to manipulate coordinates, their position and diverse data. when testing I can see the street name on the map but i can't seem to find the data property to get.

What i am trying to do is simply get the street name based on my feature coordinates.

I logged the feature but i am can't find the data unless i missed it. I checked the API too but there is nothing mentioning streets properties.

UPDATE

As suggested I used Nominatim reverse like this

https://nominatim.openstreetmap.org/reverse.php?format=json&lat=LAT&lon=LON&zoom=16

and through a simple xhttp request like this I got the response.

       var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("demo").innerHTML =
            this.responseText;
       }
    };
    xhttp.open("GET", "ajax_info.txt", true);
    xhttp.send(); 

Source : W3C

Note I am using v3.11 and OSM.

1

I could be wrong as I'm missing informations (e.g how your code look like) but if you think that because you can see street names on a map, you can access their properties, you are doing a mistake. If your background use ol.source.OSM, it's simply an image. You can't get street names from it. If you want street names, you should better look at

  • Overpass API, a webservice that returns vector data where you can get street names. You should start with Overpass Turbo (an UI on top of Overpass API) to get started

  • a reverse geocoder (it takes a point coordinates and return an adress) like Nominatim

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.