Retrofit a web page with location data to a live map.
The data (circa Dec 2017) was inside the page source in JSON format. To clean and use it in R, one could simply copy and assign it to a variable, then source it in RStudio to fix any errors. Then it can be converted to a data.frame.
products <- '[ { "Company_Name": "1001 Pharmacies",... } ]'
companies <- jsonlite::fromJSON(products)
Next step was to extract the addresses (companies[1:100,]$Adresse), clean them of special characters and try a batch geocode online. From the KML output file, one could extract the lon/lat coordinates and match them to the companies by address.
As a result, the companies data frame gets two more columns - latitude and longitude. Saved this geocoded data in a second JSON file.xjson <- jsonlite::toJSON(companies, pretty=T)
out <- file('french.json', encoding="UTF-8")
write(xjson, file=out)
Used Javascript next to recode the data from JSON to geojson format (see file). Finally this same geojson file is presented on a Leaflet map with clustering. Clicking on a company marker will show company details just below the map.