Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Leaflet.draw plugin?

I'm having trouble with installing Leaflet.draw plugin. I've spent several hours trying to figure out how to install it, but failed. Can someone please explain to me how can I use it?

like image 809
jc k Avatar asked Jan 05 '17 05:01

jc k


2 Answers

To use the Leaflet.draw plugin, you need to add the js and css files to your html header, like so:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- Leaflet stylesheets/javascript -->
    <link rel="stylesheet" href="leaflet.css" />
    <script src="leaflet.js"></script>


    <!-- Leaflet.draw main plug in files -->
    <link rel="stylesheet" href="files/leaflet.draw.css" /> <!--add here-->
    <script src="files/Leaflet.draw.js"></script>           <!--and here-->
</head>
<body>
[...]

I keep my Leaflet.draw organized inside a files directory.

This official example Leaflet.draw webpage might come in handy. Note that they add each plug-in piece individually, but you only need to add the main source code files Leaflet.draw.js and leaflet.draw.css.

like image 111
user2441511 Avatar answered Oct 18 '22 05:10

user2441511


To install using npm:

npm install leaflet-draw

For saving in package.json:

npm install leaflet-draw --save

For global installation:

npm install -g leaflet-draw
like image 37
Syam Pillai Avatar answered Oct 18 '22 07:10

Syam Pillai