bluehalo / ngx-leaflet-draw

MIT License
88 stars 29 forks source link

Is it possible to draw semicircles? #96

Closed souzaemmanuel closed 4 years ago

souzaemmanuel commented 4 years ago

In my angular application, I use maps through the ngx-leaflet. And now we need to draw semicircles. I know there is a Leaflet-semicircle extension, but I have already installed this dependency via Angular, but I cannot use the objects to draw a semi circle. Is there any way to use the leaflet-semicircle extension in angular?

reblace commented 4 years ago

I don't believe leaflet-draw supports semi-circles. If the leaflet-semicircle extension is an add-on for leaflet-draw, you could try following some of the examples here (https://github.com/Asymmetrik/ngx-leaflet-tutorial-plugins) to see about adding Leaflet plugins.

I haven't updated those projects in a while, but the basic approach to integrating the plugins is still the same. You might also get more guidance on Stack Overflow as this sort of question is a bit out of the scope of this library.

souzaemmanuel commented 4 years ago

Ok, I found the correct way to draw semicircles. The problem was that in addition to installing the Leaflet-semicircle extension via npm I needed to import the javascript file properly.

Just follow the steps:

npm i leaflet --save  
npm install --save leaflet-semicircle

In angular.json file add the libraries as follows:

"scripts": [
        "node_modules/leaflet/dist/leaflet.js",
        "./node_modules/leaflet-semicircle/semicircle.js"
    ]

And finaly, the problem was here:

 import 'leaflet';
    import 'leaflet-semicircle';

    //Right way to import and extend all extensions importeds previously
    declare let L;

    //Doesn't works */
    //import * as L from 'leaflet';