Giter Site home page Giter Site logo

Leaflet.draw about ui-leaflet HOT 4 OPEN

angular-ui avatar angular-ui commented on May 22, 2024
Leaflet.draw

from ui-leaflet.

Comments (4)

nmccready avatar nmccready commented on May 22, 2024

From @Martijnvl on March 29, 2014 21:11

I got that same issue, maybe someone can help use out with a working example. Much tnx

from ui-leaflet.

nmccready avatar nmccready commented on May 22, 2024

From @ninniuz on April 3, 2014 16:9

As a workaround I had to create a L.Control.Draw in my controller, define options there and add a drawnItems in my scope.

var drawnItems = new L.FeatureGroup();
var options = {  edit: { featureGroup: drawnItems } };
var drawControl = new L.Control.Draw(options);
angular.extend($scope, controls: { custom: [drawControl] });

Then simply add the layer to drawnItems when you get the draw:created event.

from ui-leaflet.

nmccready avatar nmccready commented on May 22, 2024

From @Martijnvl on April 7, 2014 21:11

I did they exact same thing but for some reason when I draw a circle for example I don't see it getting painted on the layer...see my ctrl code below. I placed the css files inside my index.html. I can't figure out why this isn't working. I do see that the layer gets added to drawitems but nothing shows on map. Any help would be appreciated.

var drawnItems = new L.FeatureGroup();

var options = {
    edit: { featureGroup: drawnItems
    },
    draw: {
        polygon: {
            shapeOptions: {
                color: 'purple'
            }
        },
        circle: {
            shapeOptions: {
                stroke: true,
                weight: 4,
                color: 'blue',
                opacity: 0.5,
                fill: true,
                fillColor: null, //same as color by default
                fillOpacity: 0.2,
                clickable: true
            }
        }
    },
    showRadius: true
};

var drawControl = new L.Control.Draw(options);

angular.extend($scope, {
    defaults: {
        scrollWheelZoom: false
    },
    london: {
        lat: 51.505,
        lng: -0.09,
        zoom: 8
    },
    controls: {
        custom: [drawControl]
    }
});

leafletData.getMap().then(function (map) {
    map.on('draw:created', function (e) {
        var type = e.layerType,
            layer = e.layer;

        if (type === 'circle') {
            console.log(JSON.stringify(layer.toGeoJSON()));
        }

        drawnItems.addLayer(layer);
    });
});

from ui-leaflet.

nmccready avatar nmccready commented on May 22, 2024

From @muenchdo on April 24, 2014 13:23

@Martijnvl Is it possible that you have missed adding the drawnItems to your map? I did it like this:

leafletData.getMap().then(function(map) {
    map.addLayer(drawnItems);
});

Now I can at least add new shapes to the map. But somehow I have some strange issues with the editing functionality. Sometimes I can edit, but after adding a new shape the editing button is suddenly disabled. Then, after adding another shape, editing is suddenly possible again. I haven't been able to track down the reason for this behaviour.

EDIT: I have further investigated my issues and it seems that every time I add a new shape, the editing toolbar is toggled. Does anybody have any ideas what could be causing this?

from ui-leaflet.

Related Issues (20)

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.