Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@asymmetrik/angular2-leaflet-draw
Advanced tools
Angular 2 component for the draw plugin for Leaflet
IMPORTANT NOTE: This package has been renamed to @asymmetrik/ngx-leaflet-draw
Leaflet Draw extension to the @asymmetrik/angular2-leaflet package for Angular 2 Provides Leaflet Draw integration into Angular 2 projects. Compatible with Leaflet v1.0.x and Leaflet Draw 0.4.x
Now supports Angular v4, Ahead-of-Time compilation (AOT), and use in Angular-CLI based projects
Install the package and its peer dependencies via npm:
npm install leaflet
npm install leaflet-draw
npm install @asymmetrik/angular2-leaflet
npm install @asymmetrik/angular2-leaflet-draw
If you intend to use this library in a typescript project (utilizing the typings), you will need to also install the leaflet typings via npm:
npm install @types/leaflet
npm install @types/leaflet-draw
If you want to run the demo, clone the repository, perform an npm install
, gulp dev
and then go to http://localhost:9000/src/demo/index.html
To use this library, there are a handful of setup steps to go through that vary based on your app environment (e.g., Webpack, ngCli, SystemJS, etc.). Generally, the steps are:
For more details and examples, refer to the Angular 2 Leaflet plugin README.
For leaflet to work, you need to have the leaflet stylesheets loaded into your application.
If you've installed via npm, you will need to load ./node_modules/leaflet/dist/leaflet.css
abd ./node_modules/leaflet-draw/dist/leaflet.draw.css
.
How you include the stylesheet will depend on your specific setup.
This project is exported using UMD and it includes typings. So, you shouldn't have to do anything special to use it if you're building your project in Typescript. Before you can use the module in your Angular 2+ app, you'll need to import it in your application. Note that you also need to import the angular2-leaflet module as well.
For example, in your app.module.ts
, add:
import { LeafletModule } from '@asymmetrik/angular2-leaflet.module';
import { LeafletDrawModule } from '@asymmetrik/angular2-leaflet-draw.module';
...
imports: [
...
LeafletModule.forRoot(),
LeafletDrawModule.forRoot()
]
...
To create a map, use the leaflet
attribute directive. This directive must appear first.
You must specify an initial zoom/center and set of layers either via leafletOptions
or by binding to leafletZoom
, leafletCenter
, and leafletLayers
.
Finally, add the leafletDraw
attribute directive to add the leaflet draw control and configure it with leafletDrawOptions
.
<div leaflet style="height: 400px;"
leafletDraw
[leafletOptions]="options"
[leafletDrawOptions]="drawOptions">
</div>
This attribute is an attribute directive that initiates the draw plugin.
Input binding for the options to be passed to the draw plugin upon creation. These options are only currently processed at creation time.
drawOptions = {
position: 'topright',
draw: {
marker: {
icon: L.icon({
iconUrl: '2273e3d8ad9264b7daa5bdbf8e6b47f8.png',
shadowUrl: '44a526eed258222515aa21eaffd14a96.png'
})
},
polyline: false,
circle: {
shapeOptions: {
color: '#aaaaaa'
}
}
}
};
The options object is passed through to the Leaflet.draw object. Therefore, you can reference their documentation for help configuring the draw control.
If you do not provide a featureGroup
for the Leaflet.draw plugin to use, the leafletDraw directive will create one internally and put it in the options object.
If you want to toggle the draw control on and off, you can use the following approach:
<button (click)="shown = !shown">Show/Hide Control</button>
<div leaflet style="height: 400px;"
[leafletOptions]="options">
<div *ngIf="shown"
leafletDraw
[leafletDrawOptions]="drawOptions"></div>
</div>
You can place the leafletDraw directive on a child element and then use *ngIf to add/remove the draw control from the map. When ngIf evaluates to false, the child element is removed from the map, which destroys the control. When it evaluates to true, the child element is added to the map, which recreates the control.
PRs accepted. If you are part of Asymmetrik, please make contributions on feature branches off of the develop
branch. If you are outside of Asymmetrik, please fork our repo to make contributions.
See LICENSE in repository for details.
Leaflet Is an awesome mapping package. Leaflet.draw Makes drawing shapes on maps super easy.
FAQs
Angular 2 component for the draw plugin for Leaflet
The npm package @asymmetrik/angular2-leaflet-draw receives a total of 6 weekly downloads. As such, @asymmetrik/angular2-leaflet-draw popularity was classified as not popular.
We found that @asymmetrik/angular2-leaflet-draw 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.