This an attempt to create a GeoGuessr style game for iNaturalist. This web application integrates with the iNaturalist API to create an interactive game where users can guess the location of observed species and earn points based on the accuracy of their guesses.
- Click the "Play Game" button to start the game.
- A species observation image will be displayed, and a map will show the world's regions.
- Your task is to guess the location where the species was observed by clicking on the map.
- After making your guess, the actual location will be revealed, and you'll earn points based on the accuracy of your guess.
- The game consists of multiple rounds, and your total score will be displayed at the end of each game.
- Use the "Next Round" button to proceed to the next round and continue playing.
-
Interactive Map: The game includes an interactive map that allows you to make guesses about the location of observed species. Click on the map to make your guess.
-
Scoring: The game calculates your score based on the distance between your guess and the actual location. The closer your guess, the more points you earn.
-
Customization: You can customize your game experience by adding custom parameters to the URL. For example, you can set a specific seed for the game, focus on specific places, or narrow down the taxonomic group you want to guess.
-
Daily Challenge: Activate the daily challenge mode by setting the seed to "daily" and the game will use the current date as the seed for a unique challenge every day.
-
Custom Place and Taxon Information: The game can display information about custom places and taxonomic groups if specified in the URL parameters.
-
Clipboard Copy: Easily copy your game scores to the clipboard for sharing or keeping a record.
The iNaturalist Species Guessing Game is built using JavaScript and leverages the iNaturalist API to fetch species observations. Here's how the code works:
-
Initialization: The code initializes various global variables and retrieves custom parameters from the URL, allowing for customized gameplay.
-
Seeding: The game can be seeded using a provided seed or set to the daily challenge mode. Seeds influence the random observations generated in each round.
-
Fetching Observations: The
getRandomObvs
function fetches a random species observation from the iNaturalist API based on the specified parameters, including custom places and taxonomic groups. -
Fetching supporting obvservations: The
getSupportingObvs()
function gets other observations from the nearby area. -
Creating the Map: The
createMap
function initializes an interactive map using Leaflet.js. It displays the secret location and allows users to make their guesses by clicking on the map. -
Scoring: The game calculates your score based on the accuracy of your guess. The
calculateScore
function determines the score based on the distance between your guess and the actual location. -
Displaying Information: The game displays custom place and taxonomic group information based on the URL parameters.
-
Generating Rounds: The
generateNewRound
function generates new rounds of the game, updating the map, fetching observations, and handling custom parameters. -
Event Listeners: Event listeners are set up for buttons like "Play Game," "Next Round," and "Copy to Clipboard," enhancing the interactivity of the game.
- Clone this repository to your local machine.
- Open the
index.html
file in a web browser. - Click the "Play Game" button to start playing the iNaturalist Species Guessing Game.
You can customize your game experience by adding custom parameters to the URL. For example:
- To set a specific seed for the game, add
?seed=YOUR_SEED
to the URL. - To focus on specific places, add
?place_id=PLACE_ID1,PLACE_ID2
to the URL. - To narrow down the taxonomic group, add
?taxon_id=TAXON_ID1,TAXON_ID2
to the URL.
This game is powered by the iNaturalist API, Leaflet.js, and seedrandom