Git Product home page Git Product logo

Comments (10)

bbecquet avatar bbecquet commented on September 26, 2024 2

Ok, this is exactly what was suggested in this previous issue #11.

I personally liked the way Leaflet classes can be dynamically extended without having to create a new class, but maybe it's not suited to big real-life projects. And I understand how it conflicts with the static typing approach.

I guess I'll do the shift to the modular approach when I have some time soon. After that, if you want to add a TypeScript def file to the project, I would be happy to accept a PR :)

from leaflet.rotatedmarker.

blueromans avatar blueromans commented on September 26, 2024 2

same issue on ionic project with leaflet.

from leaflet.rotatedmarker.

f-loris avatar f-loris commented on September 26, 2024 2

I think this issue is already solved. Type defintions are provided here: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/leaflet-rotatedmarker

See my answer on stackoverflow: https://stackoverflow.com/questions/45479872/leaflet-map-rotated-marker-for-ionic2-typescript/51063718#51063718

from leaflet.rotatedmarker.

bbecquet avatar bbecquet commented on September 26, 2024

Hi Ferouk,

Thanks for using this plugin, glad to know it's useful to you :)
I've never used TypeScript first-hand myself. But if I'm not mistaken, TypeScript is only a superset of Javascript which basically adds annotations, so any valid JS code is supposed to be valid TypeScript as well. So I guess it should work as-is. But I've not tested it so I may completely overlook some problems.

Can you describe the problems or incompatibilities you encounter?

from leaflet.rotatedmarker.

Ferouk avatar Ferouk commented on September 26, 2024

Hi bbecquet,
Thanks for the quick reply.

In order to resolve leaflet rotateMarker in Typescript, a Typings definition is required otherwise it won't be imported to the project properly. I tried to create a typings definition but I failed mainly because of the L.Marker.include().

The issue is that the class Marker in The "official" Leaflet typings can't be extended, it has to be overriden.

I suggest a modular approach. I mean var L.RotatedMarker= L.Marker.extend().

from leaflet.rotatedmarker.

MaddyMastering avatar MaddyMastering commented on September 26, 2024

I am trying to migrate from angular 1 to angular 2 and was successful in creating definitely typed files for other leaflet plugins. But this one seems to be very confusing. It would be very helpful if anyone has any of using this in typescript project.

from leaflet.rotatedmarker.

Ferouk avatar Ferouk commented on September 26, 2024

@bbecquet I'll be glad to help

@MaddyMastering A temporary alternative to migrate is by using L.divIcon with inline css
https://stackoverflow.com/a/45506208/2897052

from leaflet.rotatedmarker.

badis avatar badis commented on September 26, 2024

How about writing a type definition file. this article looks interesting: https://peter.grman.at/how-to-write-typescript-definition-files/

from leaflet.rotatedmarker.

afeezaziz avatar afeezaziz commented on September 26, 2024

Hi @Ferouk , have you managed to get a workaround for this? I am using Typescript and Angular too.

from leaflet.rotatedmarker.

Ferouk avatar Ferouk commented on September 26, 2024

@afeezaziz I've used L.divIcon instead with style attribute to control the icon rotation. This is an example:

L.divIcon({
  html: '<img class="leaflet-marker-icon leaflet-zoom-animated" src="[icon image URL]" style="width: [icon width]px; height: [icon height]px;transform: rotate([angle]deg);  -webkit-transform: rotate([angle]deg); -moz-transform:rotate([angle]deg);" />'
});

from leaflet.rotatedmarker.

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.