NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Can I get data from the OSM by sending a javascript request for it ? I mean data like what is shown when you do a search on the OSM map? (any data is welcome). Can that be done based on lat/lon ?

If yes, where can I find the documentation how to do that? </blush>

asked 15 Sep '23, 14:20

Treklov's gravatar image

Treklov
10223
accept rate: 0%

1

This is quite vague. What kind of query do you want to run?

(16 Sep '23, 22:15) InsertUser

I am looking for something similar as with google maps places in javascript for android, like the following, but then for OSM.

function getPlacesData(query) { const url = https://maps.googleapis.com/maps/api/place/textsearch/json?query=${query}&key=${apiKey};

fetch(url) .then(response => response.json()) .then(data => { // Extract relevant information from the API response const places = data.results.map(result => { return { name: result.name, address: result.formatted_address, rating: result.rating, phone_number: result.formatted_phone_number, website: result.website, types: result.types, opening_hours: result.opening_hours, photos: result.photos, geometry: result.geometry.location, // lat/lan }; }); }) .catch(error => { // Handle errors console.error(error); }); }

Can someone tell me if something like this exists for OSM and where I can find it?

(17 Sep '23, 03:24) Treklov

I think you can. An app that I use quite often is GPS Prune. I needs Java to operate and displays a GPX over a map drawn from OSM data. I think the source code, of the app, is available. It may give you a good starting point for what you wish to do. see https://activityworkshop.net/software/gpsprune/

The JOSm editor and the latest version of the Potlatch editor also use Java and they certainly shows OSM data. I'm not sure if OSM object to us disassembling either of these tools.

permanent link

answered 17 Sep '23, 14:53

andy%20mackey's gravatar image

andy mackey
13.2k87143285
accept rate: 4%

edited 17 Sep '23, 15:05

1

I've never looked, but I suspect that all the Potlatches are ActionScript (for Flash). It's successor, iD, is written using JavaScript.

(17 Sep '23, 15:04) SomeoneElse ♦

The short (but unhelpful) answer is "yes".

However, OSM is not like Google - you do not have to interact with it through the keyhole of an API;you can just download it and extract what you want with it (subject to copyright restrictions, which for you probably means accreditation).

There are APIs available from third-parties that allow you to query their extract of OSM data, but we won't know which will be useful to you because we don't know what you actually want to do.

I'm guessing, but I'd suggest that "overpass" might be a possible starting point. Have a look in the OSM wiki for that.

permanent link
This answer is marked "community wiki".

answered 17 Sep '23, 15:09

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866
accept rate: 16%

edited 17 Sep '23, 15:09

Great ! Thanks very much sofar.

I had a look at GpsPrune, but it uses Java and my webpage(s) does everything with coordinates and positioning in javascript. The web site is/are a few pages that are loaded in webviews into an android app. I have little Java coding in the app, just for permissions, intent processing and back buttons ;-) So the logic I have mostly in Javascript.

I will have a look at the he JOSm editor, when not Potlatches with ActionScript then iD and the overpass in the OSM wiki too. Third party software..maybe.

I will tell you soon.

permanent link

answered 17 Sep '23, 16:20

Treklov's gravatar image

Treklov
10223
accept rate: 0%

I am looking for a way to detect a difference in color on a map, but I can't find it or get it to work (yet) on a google map with a canvas.

So I was thinking of using an api to just get the color at a certain coordinate with an Open Street Map. That would also be a good start to detect areas with water btw. But I haven't found a simple solution yet. If OSM would give the data like if something is a building or a forest at a certain coordinate, that could also work for me. I have google maps set up, but with a coordinate I could do something with OSM in parallel.

I will keep looking. If I find something, I will post it. Thank you!

permanent link

answered 18 Sep '23, 07:58

Treklov's gravatar image

Treklov
10223
accept rate: 0%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×535
×230
×202
×60

question asked: 15 Sep '23, 14:20

question was seen: 1,297 times

last updated: 18 Sep '23, 07:58

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum