I've mapped the bicycle sharing stations of Salvador (Bahia, Brazil) and I would like to show these stations on a map. When there was only five stations I created manually a GeoJSON file using geojson.io and it generated a map to embed in a page. But now there is 19 sharing stations! It would be a lot of repeated work to map the stations on OSM and after create the geojson manually.
So I discovered the osmfilter, a useful software to filter OSM data. Combining osmfilter and geojson.io you can extract data from OSM and show that information on a personalized map. So let's go to the instructions.
The first step is to download the OSM data from the region you want. On my case, I used JOSM to download all the data of the city and saved the .osm file on my disk.
Now we need to use osmfilter to extract the desired data from the osm file. Access the page osmfilter in the OpenStreetMap wiki to see the installation instructions. The command I used to filter only the bicycle sharing stations was:
./osmfilter salvador.osm --keep="amenity=bicycle_rental" > bikesalvador.osm
You can combine more than one filter, for example if you want to filter all the italian restaurants you would use --keep="amenity=restaurant and cuisine=italian". The last part of the command is the file to where you want to save the filtered data.
Now go to geojson.io, click on the button "Open" and import the osm file generated by osmfilter.
You will see all the data you filtered including the metadata. If some metadata isn't important to you, you can drop one or more columns. You will need an account on GitHub to save your geojson. After save, GitHub will give you a gist page of your geojson including a embed code that you can use to put the map on another webpage.
If you want to learn how to add a GeoJSON layer to Leaflet, I recommend that tutorial by Lyzi Diamond.