Giter Club home page Giter Club logo

react-leaflet-distortable-imageoverlay's Introduction

react-leaflet-distortable-imageoverlay

Scale, skew, rotate and translate image overlays in react

NPM JavaScript Style Guide

A react-leaflet ImageOverlay that supports stretching, skewing, distorting, rotating, translating and transparency. It is designed to allow positioning and rectification of aerial, drone and UAV imagery on a react-leaflet map.

It was built for the Soar platform by extending the functionality of Leaflet.DistortableImage and Leaflet.Path.Transform

Live Demo

Demo

Install

npm install --save react-leaflet-distortable-imageoverlay

Usage

The ReactLeafletImageOverlay component takes the corners of the ImageOverlay and updates the parent on changes with the onWellKnownTextUpdated and onCornersUpdated handlers. The editMode can be one of: 'rotate', 'translate', 'distort' and 'scale'. The component itself has no toolbar or ability to switch between the edit modes so you should set them as state with a button or something (see example).

import React, { Component } from 'react'
import { Map, TileLayer } from 'react-leaflet'
import ReactDistortableImageOverlay from 'react-leaflet-distortable-imageoverlay'

class Example extends Component {

	onWellKnownTextUpdated(wkt) {
		console.log(wkt);
	}

	onCornersUpdated(corners) {
		console.log(wkt);
	}

	render () {
		return (
			<Map bounds={[[43.786293, 15.647650,0],[43.686293, 15.547650,0]]}>
				<TileLayer
				noWrap={true}
				attribution=""
				url="http://mt0.google.com/vt/lyrs=s&x={x}&y={y}&z={z}"/>

				<ReactDistortableImageOverlay 
					url="example.jpg"
					editMode={this.state.editMode}
					onCornersUpdated={this.onCornersUpdated.bind(this)}
					onWellKnownTextUpdated={this.onWellKnownTextUpdated.bind(this)}
					corners={[
						new L.latLng(43.78710550492949,15.647438805314396),
						new L.latLng(43.78710550492949,15.655914504316957),
						new L.latLng(43.78098644922989,15.647438805314396),
						new L.latLng(43.78098644922989,15.655914504316957)
					]}
				/>
			</Map>
		)
	}
}

License

MIT © ChrisLowe-Takor

react-leaflet-distortable-imageoverlay's People

Contributors

bradcrawford avatar chrislowe-takor avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.