Application maptest at shinyapps.io displays our data. Developing in RStudio; published at shinyapps.io; version control in github.
To develop further, Barb is using RStudio on her Windows laptop.
Additional documentation is in this google doc, including a road map for development, and development notes.
"Barb's Dev Doc" may also have helpful information.
The code itself has documentation; see the README.Rmd
The software is archived in github: https://github.com/bidwbb/maptest
It is developed in ~/Documents/R/maptest on Barb's laptop.
It is published directly from RStudio to shinyapps.io.
File app_server.R:
The data to show the map locations on the left is made entirely from the maps spreadsheet that we manually curate.
The data to show the course maps on the right (including what locations are shown in the menus) is a combination of the spreadsheet and the actual file structures.
Both these datasets need to be updated manually. To update from the spreadsheet, we use loadLocations(). To update from the drive (takes a looooong time), we run
filtered_locinfo() is a reactive data structure made from locinfo()
locinfo() is a reactive value made from readCachedLocData(), which is defined in fct_loadMapData.R
To update the data/locations.rds file that is used to display all map locations, run loadLocations().
We have several versions:
Our manually curated database of maps is "Maps and Courses for Navigation Games" here, in the MapsArchive google drive. Only the first, "Maps", tab is up to date. Maps are added manually to this file. You must provide coordinates for the map to be visible in the software application. This is the source of data for the R Shiny application.
"Test" in the MapsArchive drive was made for doing some programmatic work in January 2024, last edited by Jackson Codd. Test has 202 rows.
Map Tracking (Maps drive) has 232 maps with x y location and shows the organization. Jackson used this file for getting the coordinates from the address of the map. See the associated Apps Script. The script does the following. Some addresses are wrong (eg VLUS) for various reasons. So you will need to edit some by hand.
Get folder by ID 0AO9KdmEaEGYGUk9PVA (this is our Maps drive)
Get the folders in that drive and look recursively at the country, region, city, and location levels for map names. Split the map name to get the type and owner
Write a new row with the information.
(Barb created an additional function that just gets the geolocation of each place, as opposed to each map.)
Map missing info has 224 rows with the folder hierarchy
Note that it should be possible to do the geocoding in R. You may need to provide a google key for this service. Other option: tidygeocoder
data/locations.rds stores map data read from Google sheet "Maps and Courses for Navigation Games".
data/md.rds stores map and course data read by walking through the Maps Google Drive.
The data:
LOCATIONS - from Test in MapsArchive - this is what is displayed by the UI.
output$locations is output of googleway::renderGoogle_map() using filtered_locinfo() as data. filtered_locinfo() takes data from llocinfo(), from readCachedLocData()
[Not currently used: output$loctable takes data from locinfo()]
readCachedLocData() is defined in file fct_loadMapData.R. It takes data from data/locations.rds or (if missing) runs loadLocations() which gets the data from google_loc_id. It sets up the Icon and INFO2 (html with various fields)
loadLocations() is defined in file fct_loadMapData.R. It reads google sheet using an ID defined in the golem config file (Maps and Courses for Navigation Games, our main manually curated spreadsheet). It performs the following operations:
Ensure that x and y are single items, not lists, by reading the first element. (Commas might have been left in when copying in the x,y coordinates)
Set color based on owner.
Require LocationName, x and y to be columns in the spreadsheet.
Set new colunn INFO2 to be HTML combining various information about each map.
Save to data/locations.rds and return the data structure.
1_1KMmJUEUoitLyCXYQ-c-6NmM_chGJ4RVynDH8VLJGg
Displayed: x and y for lat and lon. info window has INFO2.
MAP - from Map Tracking in Maps -- 4/5/25: this appears to not be used any longer.
output$map takes data from gmap(), with data from filtered_mapinfo(), with data from mapinfo(), from readCachedMapData(), which reads data/maps.rds or, if missing, runs loadMapData()
reloadMapInfo button triggers loadMapData()
fct_loadMapData.R contains loadMapData() which reads from golem config "google_db_id". It changes any owner other than Navigation Games, NEOC, CSU adn OUSA to "Other". It sets up color and icon. by owner. It sets up INFO (text) and INFO2 (html). It sets up Link to Image. It saves as data/maps.rds.
1lnKOlxuZzsP6HBm0zW1X1YrGZPskMU3W0MEFLtNcT9I
Bug: when click on a teardrop (the Somerville park that David & Zack & others worked on) in the app, I get an error:
Error in [.data.table: i evaluates to a logical vector length 182 but there are 184 rows. Recycling of logical i is no longer allowed as it hides more bugs than is worth the rare convenience. Explicitly use rep(...,length=.N) if you really need to recycle.
FIX: change the type of the x and y columns to "Text" in the google spreadsheet. Then reload (maps <- loadLocations()), and try again.
renv::status() reports that covrpage is used in this project but not installed. Documentation suggests that this is used in 02_dev.R to create a summary readme for the testthat subdirectory. For now I'll comment it out (4/5/25). Rerunning renv_status() now gives me a list of packages that are installed but not recorded in the lockfile. This includes things like googledrive, DT, shinydashboard, mpatest itself, gargle, and others. I added these as prompted to the renv lock file. Not really sure what all that is doing.
Add images to popup
Zoom in on Cambridge
Popup closes when another one opens
Get the icon coloring to work
Make the owner filter work; change to checkboxes and show all be default. Keep original owner and just use "other" for coloring.
Check that version control is working
Check what version is published
Combine spreadsheets into one.
Map Tracking has xy locations from code, and was built from the drive. If one is NA, use the other. If different, use Test. Easy way: (1) start with Test. (2) Where you have NA, use Map Tracking
Has: Country, Region, City, LocationName, Address, Map Type, x, y, Location (x,y), Link to Image, Owner (all NA), Mappers (ditto), Date, Location Folder, Link to PDF, Type, ISSOM/ISOM? Hand Iso? Sketchup? OOM?
Test has manually curated info
Has: Region -> State/Province; Location -> GeoLocation. Owner is populated.
Combine Map Tracking + Test. Prioritize Map Tracking. Fix things that are in one but not the other by making changes in the spreadsheets directly.
Combine #3 with Maps & Courses for NG. Prioritize Maps & Courses. Fix things in one but not the other by making changes in the spreadsheets directly.
Create report of items in sheet that are not in the drive (might have been renamed)
Add maps that are in the drive but not in the sheet
Add x y locations that are missing
Check that links are working
Monday.com has a map viewer, that could be shared publicly. However, it requires a location column to which you can't import. You can edit it programmatically, but I don't see an easy R interface. I also couldn't easily figure out how to add the other fields to display in the popup when you click on "View Item". So I'm going back to using the R Shinyapps.io code.
We have a number of Google "My Maps" that show locations of maps, schools and so on. "My Maps" is used to record your own set of locations; it has limited functionality. For us we need something that allows us to group points by different categories. I was able to use it for a nice display of maps we have created; it works great for that. You can overlay maps in KML and maybe other formats. Article about alternatives (2018). One thing I'd like is for the database of locations to be sourced in a spreadsheet. We can get a free account on Place.Guru with max 10 lists and 3 custom markers. It gets VERY expensive after that, and does not have all of the features of My Maps.
Here are our Google My Maps attempts, pulled together August 2020. We should probably consolidate these. It can be useful in working with multiple private and public schools in one area, and prioritizing our outreach and map-making. Strangely, most of these were made from my barb.bryant@gmail account as opposed to Navigation Games. My Maps does not have any kind of folder or organizationsl option - it's very simple.
Navigation Games Maps 2020. This is our main tool for seeing where maps are. It's great. We have different colors for others' maps (CSU, NEOC), our finiahed maps, and locations we want to map. We show the schools and after-schools.
Test overlay orienteering maps. I apparently imported data from OCAD or elsewhere - it has contours of Boojum Rock map overlaid on Google Maps. Must have been an experiment though I do not recall the purpose.
Other solutions from googling 1/12/24. Note. even if we didn't overlay the map, we could have just point locations shown.
World of O (omaps.worldofo.com) should be perfect - especially if we can filter to find school maps - but I recently (2023) had trouble with uploading a map.
Carto.com - this might scale well. Very powerful.
Google Earth - can do overlay of georeferenced maps (Import > KML), but some chatter about difficulty sharing with others. might try online Google Earth online browsers, earth.google.com/web/ (different from Google Earth Pro). You can import KML files into web Google Earth projects, and share publicly. Loads slowly; hardware acceleration is helpful.
Map Warper. Overlays on an OpenStreetMap basemap. Users can download the georeferenced image.