Tiny OSM (Open Street Maps) API Wrapper
npm install osm-dudenpm i osm-dude
const OsmDude = require('osm-dude');
const osm = new OsmDude(
lat, // float center latitude value
lon, // float center longitude value
latCoverage, // float total distance across latitude value
lonCoverage, // float total distance across longitude value; optional
{
mapWidth: mapWidth, // value to map the coordinate boundaries to in the x-dimension; defaults to 1
mapHeight: mapHeight // value to map the coordinate boundaries to in the y-dimension; defaults to 1
} // settings
);
osm.init();
`
> 💡 Pro-tip: Utilize the test file as an example
📃 Documentation
$3
* where elementInteractions is a customizable interface for programs that wish to run with more detailed Open Street Map functionality; optional.
* elementInteractions can also be set later on by calling setFeatureData).
* asynchronous; returns once instance has been initialized.
* returns nothing.
$3
* returns true if any OSM data has been loaded.
* returns false if no OSM data has been loaded.
$3
* renders each element according to the customizable, optional element renderer declared in setElementRenderer.
* returns nothing.
$3
* where vel is an object of keys lat and lon which represent the distance desired to travel to a new coordinate.
* asynchronous; returns once incoming data has been accounted for.
* returns nothing.
$3
* where player is a supposed object of keys x and y representing a relative position within the mapped bounds of the OsmDude instance.
* returns an array of OsmElement instances which overlap with the player's 2d position.
$3
* where elementInteractions is a detailed object that helps your program know what to do based on an occurring landmark or what-have-you.
* an example sheet can be found here.
* returns nothing.
$3
* where els is an array of OsmElement instances; intended to be used in conjunction with the result of getCollisions.
* returns the data specified in the pre-defined element interactions from setFeatureData.
$3
* where player is a supposed object of keys x and y representing a relative position within the mapped bounds of the OsmDude instance.
* this is an alias who's input acts as getCollisions's and who's output acts as getElementInteractions's.
* therefore, shares the same input convention as getCollisions and the same output convention as getElementInteractions.
* returns all of the element interactions of all of the elements physically overlapping the player's coordinates.
$3
* returns the data parsed from the Open Street Map API's response.
$3
* returns an array of OsmElement instances.
$3
* where bounds is an object of keys minLat, minLon, maxLat, and maxLon.
* returns nothing.
$3
* where w and h are the respective mapWidth and mapHeight values from the initialization example.
* returns nothing.
$3
* where elementRenderer is a function that takes arguments el and offset. el is an OsmElement instance and offset is an object of keys x and y which represents the mapped distance from the center traversed without reloading. If traverse has never been called, offset is negligible.
* intended to render to a visual representation of all the elements of the loaded map. Some visual frameworks can be found here.
* returns nothing.
$3
* returns an element interactions template as seen here.
$3
* returns an object with data detailing the furthest points of the current pool vertices given by the OSM data.
* This may be useful for debugging purposes.
$3
* intended for debugging purposes.
* prints to the console a summary of the data within the OsmDude` instance.