Giter Club home page Giter Club logo

leaflet.editinosm's Introduction

Leaflet.EditInOSM

This simple control provide link to edit the map current view in the OSM editors.

Check out the demo.

To see some of the newer features, see the Examples section below.

Out-of-the-box supporter editors:

  • iD
  • Potlatch 2
  • JOSM

Quickstart

Add the js and css script tags to your project after leaflet:

<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.6/leaflet.js"></script>
<link rel="stylesheet" href="./Leaflet.EditInOSM.css" />
<script src="./Leaflet.EditInOSM.js"></script>

When you instantiate the Leaflet map, specify the editInOSMControlOptions option to activate the control:

    var map = L.map('map', {
        editInOSMControlOptions: {},
    });

Control Configuration Options

option description
position standard for a Leaflet control. See the Leaflet documentation.
zoomThreshold An integer representing the minimum zoom level for which this control is visible.
widget The UI widget that will appear for this control. Can be a string value of attributionBox or multiButton. Or, can be a configured instance of a class from L.Control.EditInOSM.Widgets. See examples for more details.
editors An array of editors to determine which editors will appear in the UI widget. Can be string values of id, potlatch or josm for the built-in editors, or configured instances of L.Control.EditInOSM.Editors. See examples for more details.

Widgets

The EditInOSM control supports two types of UI widgets, each with different goals.

multiButton

A box icon that reveals selectable options when the user hovers over it. This is perfect for situations where you expect the majority of your users to be enthusiastic about contributing to OpenStreetMap and you want to make it as easy as possible.

attributionBox

A small hyperlink, styled like an attribution box typically found in the bottom-right of a web map. This is great for situations in which your app makes use of OpenStreetMap and you want users to contribute back, but don't want to distract your user from the primary features of your application. Pairs great with a high zoom threshold.

Overriding the URL of an existing editor

In editInOSMControlOptions key in the map options, provide the editors option with the desired overrides.

example:

var overriddenId = new L.Control.EditInOSM.Editors.Id({ url: "http://www.example.com" }),
    map = L.Map('map', {
    editInOSMControlOptions: { editors: [overriddenId, 'potlatch'] }
});

Adding additional editors

Provide an object to the editors option with the following properties:

property description
displayName The name to appear on the button.
url The url prefix to pack a location onto
buildUrl a function that takes a base url and builds it into a location-aware url using the map object.

example:

var foo = { displayName: "Foo",
            url: "http://www.example.com",
            buildUrl: function (map) { return this.url; }
          },
    bar = { displayName: "Bar",
            url: "http://www.example.com",
            buildUrl: function (map) { return this.url + "/example.html"; }
          },
    map = L.map('map', { 
    editInOSMControlOptions: { editors: ['id', foo, bar] }
    });

Other customizations

Check out some examples:

leaflet.editinosm's People

Contributors

yohanboniface avatar jfirebaugh avatar mvexel avatar perliedman avatar chatelao avatar sabas avatar

Stargazers

 avatar Jinghao Hu avatar Steven Vance avatar Mikkel Kirkgaard Nielsen avatar  avatar Stefan R. Grotz avatar Juan avatar Erdong avatar Bratu Ionut avatar thdtjsdn avatar Nathan Bersez avatar albert avatar  avatar Matt Krick avatar Michael Donnelly avatar olamedia avatar  avatar Maxim Dementyev avatar Alexandre Magno avatar Thomas Gratier avatar Jeremy Heffner avatar Richard Finegold avatar Marc Sibert avatar elf Pavlik avatar  avatar Ben Abelshausen avatar Karim Kiatlottiavi avatar  avatar Kristofor Carle avatar Gabriel Nahmias avatar Coleman McCormick avatar  avatar Leigh Hunt avatar Robert Seyfriedsberger avatar Robin Gower avatar Drew Dara-Abrams avatar  avatar Chris Dahms avatar

Watchers

 avatar James Cloos avatar Gabriel Nahmias avatar Stefan R. Grotz avatar James Davy avatar

leaflet.editinosm's Issues

I missed an "add new note" button and added it

I modified the code and added a new editor
Note: function (config) { var url = 'https://www.openstreetmap.org/note/new#map=', displayName = "Add new note", buildUrl = function (map) { return this.url + [ map.getZoom(), map.getCenter().wrap().lat, map.getCenter().wrap().lng ].join('/'); }; return { url: (config && config.url) || url, displayName: (config && config.displayName) || displayName, buildUrl: (config && config.buildUrl) || buildUrl }; },

Is this something you want in a pull request?

Add example: Potlatch2 on openstreetmap.org

For overriding editors, it would be helpful to have an example of Potlatch2 hosted on openstreetmap.org, something like:

var overriddenPotlatch = new L.Control.EditInOSM.Editors.Potlatch({
    url: "http://www.openstreetmap.org/edit?editor=potlatch2",
    buildUrl: function (map) {
        return this.url + "#map=" + [ map.getZoom(), map.getCenter().wrap().lat, map.getCenter().wrap().lng ].join('/');
    }
});

Alternatively, substitute the openstreetmap.org hosting of Potlatch2 into Leaflet.EditInOSM.js and have the open.mapquestapi.com hosting as an override example.

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.