
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Hello folks, this is a js library designed to let an user easily draw shapes over an open street map and import/export them in order to make something useful, i.e. save them to a database engine.
It uses the leaflet library with the openstreetmap tiles.
Its simplest usage scenario is when you need to geolocalize some entities and save such info in the database, along with all other stuff (name, description and so on...)
It was designed with the simplicity of usage and integration as primary focus, so that it can be integrated and used in any web application backoffice with no pain:
Some features:
Just download or clone the repo
$ git clone https://github.com/otto-torino/osmdrawer.git
or use npm ;)
$ npm i osmdrawer
Include the min library (dist/osmdrawer.min.js
) in the head of your document or in the body, or load it async, it's up to you:
<script type="text/javascript" src="bower_components/osmdrawer/dist/osmdrawer.min.js"></script>
Define the map canvas container somewhere in the document:
<div id="map-canvas"></div>
Instantiate the OpenStreetMapDrawer.Map class passing some options, then call its render method. Do all this inside a callback function passed to OpenStreetMapDrawer.ready()
, in order to be sure the library is fully loaded:
<script>
var cb = function () {
var mymap = new OpenStreetMapDrawer.Map('#map-canvas', {
tools: {
point: {
options: {
maxItemsAllowed: 3,
}
},
polyline: {},
polygon: {},
circle: {}
},
exportMapCb: function (data) {
console.log('exported data: ', data);
}
});
mymap.render();
}
OpenStreetMapDrawer.ready(cb);
</script>
Need to import existing data?
...
mymap.render()
mymap.importMap({
point: [{lat: 45, lng: 7}],
polyline: [
[{lat: 44, lng: 7}, {lat: 44.3, lng: 7.2}]
]
});
...
The library provides some classes:
Each class has its own public methods (actually are all public in js, but some of them are not meant to be, and they start with an underscore char).
Every tool can be customize at runtime, you can add or remove tools, change options and so on...
If you have already an interface designed with buttons to export data or clear the map, that's not a problem, you can provide your own controllers for all the tools and almost all the functionalities; the library will manage (attach and detach) the events itself. The active controller receives a css class osmdrawer-selected
so that you can manage its active state.
The repository comes with a development environment involving:
The code is written following the es2015, es2016 and es2017 standards, babel is smart enough to produce a browser compatible bundle.
Get started by cloning the repository and running
$ npm install
To start development:
$ npm run dev
A server is started on http://localhost/8080, which serves the root directory. No need to run it again, changes in files are detected and the bundle is re-generated automatically, just reload the page.
The demo pages are served on http://localhost:8080/demo/
To compile for production:
$ npm run compile
To generate the library reference:
$ npm run docs
FAQs
Open Street Map Drawer Library
We found that osmdrawer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.