Leaflet.encoded | Plugin to support Google 's polyline encoding in Leaflet | Plugin library
kandi X-RAY | Leaflet.encoded Summary
kandi X-RAY | Leaflet.encoded Summary
Plugin to support Google's polyline encoding in Leaflet.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Leaflet.encoded
Leaflet.encoded Key Features
Leaflet.encoded Examples and Code Snippets
Community Discussions
Trending Discussions on Leaflet.encoded
QUESTION
I'm trying to convert a simple Javascript prototype written in a single .html file with embedded
ANSWER
Answered 2017-Sep-27 at 07:45It's tricky due to how polyline-encoded works: this plugin extends Leaflet
. So if we want it to work exactly as in JavaScript, we need to extend the leaflet types and its 1550 lines! Even more problematic, every time we want to update Leaflet
, we need to check whether its types have been updated and merge them with the polyline-encoded
types!
Another potential issue: in your code, Leaflet
is used in a ES6 module but polyline-encoded
is based on an IIFE that changes the current Leaflet
object L
, mixing old and new JavaScript ways. I'm curious to know if it works.
Anyway, a safer option that I see (but didn't test yet):
- Define new types → see
Leaflet.encoded.d.ts
below, to add to your project. - Force-cast
L
as the extended type defined inLeaflet.encoded.d.ts
:Lx.L;
. - Use
Lx
instead ofL
for every use of thepolyline-encoded
extensions.
Your code adapted:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Leaflet.encoded
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page