Skip to content

ahalota/Leaflet.draw-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Leaflet.draw-extension

Add a "shapefile" button to the leaflet draw toolbar. Shapefile needs to be in a .zip file, can be multiple shapefiles in one zip.

Example:

	drawLayers = new L.FeatureGroup();
	drawControl = new L.Control.DrawPlus({
		position: 'topright',		
		draw: {
			circle: false,
			polyline: false,
			shapefile: {
				shapeOptions:{
			    	color: 'black',
			    	weight: 3,
			    	opacity: 1,
			    	fillOpacity: 0					
				}
		    }, //Turn on my custom extension
		},
		edit: {
			featureGroup: drawLayers,
			edit: false
		}
	});

To Do: I really want this to work as an added feature to the Draw control, not needing to be an extended class. Please tell me how to do this if you know!

Tool will fire one L.Draw.CREATED event for each unique Polygon in the imported shapefile. Multipolygons will be one single event.

Requires Leaflet.draw, leaflet-shapefile, and shapefile-js plugins. Versions used when I wrote this plugin are included in this repository for convenience. If you put everything into a 'lib' folder in your final project you will have to copy the 'images' file into there too. The picture should be transparent but right now has a white background, I'll fix it some day.

About

Add a "shapefile" button to the leaflet draw toolbar.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published