Comments (8)
Hi @Tomek-Z,
please also search among closed issues.. 👉 #229
Within README there is also a section dedicated to js bundlers:
Lines 265 to 290 in bd9316b
BTW, I couldn't tell you about the missing file from unpkg.com.
👋 Raruto
from leaflet-elevation.
Hi,
Thanks for your answer. I found out that version 1.9.6 works for me. However I think that newer versions also introduce some attractive features I want to use hence I have a question.
Is there a possibility to disable dynamic imports in leaflet-elevation and loads everything statically like it was loaded before 2.0.0?
I've been looking on it since a few days and still have no idea how to merge dynamic imports with Angular and finally make it works..
from leaflet-elevation.
Hi @Tomek-Z,
in order to disable built-in lazy loader you should just statically import the dependencies of this library and expose them globally (ie. onto the window
or globalThis
object).
leaflet-elevation/src/control.js
Lines 213 to 230 in bd9316b
leaflet-elevation/src/control.js
Lines 747 to 764 in bd9316b
So to be clear, something like the following:
// external dependencies
import { d3 } from "src/assets/d3.js";
import { togeojson } from "src/assets/togeojson.js";
globalThis.d3 = d3;
globalThis.togeojson = togeojson;
// chart handlers
import { Distance } from "src/handlers/distance.js";
import { Altitude } from "src/handlers/altitude.js";
globalThis.L.Control.Elevation.Distance = Distance;
globalThis.L.Control.Elevation.Altitude = Altitude;
// or even just like that:
// const controlElevation = L.control.elevation({
// handlers: [
// Distance,
// Altitude,
// ],
// ...
// }).addTo(map);
If needed, take a look at this too: #266
👋 Raruto
from leaflet-elevation.
Thanks a lot @Raruto! Code from #266 works for me. Tomorrow I will explore all the features of leaflet-elevation with the newest version! : )
One thing left - I don't know if it's a problem, during compilation I see this, but everything seem to work fine:
./node_modules/@raruto/leaflet-elevation/dist/leaflet-elevation.js:629:35-82 - Warning: Critical dependency: the request of a dependency is an expression
from leaflet-elevation.
@Tomek-Z please also attach your final code to help others who come after you.
Warning: Critical dependency: the request of a dependency is an expression
It's a bundler related issue, search on the net for more info about it.
👋 Raruto
from leaflet-elevation.
// @ts-nocheck
import { AfterViewInit, Component } from "@angular/core";
import * as L from "leaflet";
import * as d3 from "d3";
globalThis.d3 = d3;
import * as toGeoJSON from "@tmcw/togeojson";
globalThis.toGeoJSON = toGeoJSON;
import "leaflet-geometryutil";
import "leaflet-almostover";
import "@raruto/leaflet-gesture-handling/dist/leaflet-gesture-handling";
import "@raruto/leaflet-elevation/libs/leaflet-edgescale.min.js";
import * as _ from "@raruto/leaflet-elevation/src/utils";
import "@raruto/leaflet-elevation/dist/leaflet-elevation";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"]
})
export class AppComponent implements AfterViewInit {
ngAfterViewInit(): void {
let map = L.map("map", {
center: [41.4583, 12.7059],
zoom: 5,
});
L.tileLayer("https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png", {
maxZoom: 18,
attribution: "Data © <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap contributors</a>"
}).addTo(map);
// Monkey patch the import function -> https://leafletjs.com/examples/extending/extending-1-classes.html#lclassinclude
L.Control.Elevation.include({
import: function (src, condition) {
if (Array.isArray(src)) {
return Promise.all(src.map(m => this.import(m)));
}
switch (src) {
case this.__D3:
condition = typeof d3 !== "object";
break;
case this.__TOGEOJSON:
condition = typeof toGeoJSON !== "object";
break;
case this.__LGEOMUTIL:
condition = typeof L.GeometryUtil !== "object";
break;
case this.__LALMOSTOVER:
condition = typeof L.Handler.AlmostOver !== "function";
break;
case this.__LDISTANCEM:
condition = typeof L.DistanceMarkers !== "function";
break;
case this.__LEDGESCALE:
condition = typeof L.Control.EdgeScale !== "function";
break;
case this.__LHOTLINE:
condition = typeof L.Hotline !== "function";
break;
}
// Add the ignore comment for webpack
return condition !== false ? import(/* webpackIgnore: true */ _.resolveURL(src, this.options.srcFolder)) : Promise.resolve();
}
});
const controlElevation = L.control.elevation({srcFolder: "http://localhost/src"}).addTo(map);
controlElevation.load("https://raruto.github.io/leaflet-elevation/examples/via-emilia.gpx");
}
}
from leaflet-elevation.
Hi,
I hope you're doing well.
One thing still not-working for me.
When I'm following the route on the map I can't see a tooltip in the bottom chart. No error nor warning happened.
Do you have any idea what I have to check or where to start investigation?
Tooltip exists in all your examples and I didn't find any option to enable/disable it, hence I think it is basic always enabled thing, see below - your example:
Kind regards
from leaflet-elevation.
After long debugging I found out that leaflet tooltip is conflicting with bootstrap tooltip.
In file node_modules/bootstrap/scss/bootstrap.scss
I commented line:
// @import "tooltip";
and leaflet tooltip works.
@Raruto Consider changing class naming.. I don't know : )
With this I close this thread.
All the best.
from leaflet-elevation.
Related Issues (20)
- Integration with Bootstrap framework (v3.3.7) HOT 2
- Omitting the `<ele>` tag in gpx file throws Uncaught DOMException: CanvasGradient.addColorStop: Invalid color HOT 2
- GDPR compliance - usage without unpkg.com HOT 8
- Skip distance in chart between multiple tracks HOT 7
- Hide file url and encrypt gpx data HOT 9
- How to add the Download button to a gpxGroup map HOT 2
- Android: Pointer on elevation graph HOT 2
- Change decimal and thousands separator HOT 4
- Polyline layer turns black after turning off all legend filters (`legend: true` + `preferCanvas: false`) HOT 6
- Updating a track continuously (live tracking) HOT 3
- Unsopperted GeoJSON feature geometry type:Point HOT 1
- Download link HOT 1
- How to show Elevation in decimal? HOT 3
- Marker tooltip with negative elevation HOT 1
- Polyline layer turns black after turning off all legend filters on custom colors HOT 4
- Leaflet elevation get track properties (Length, Elevation, time, etc) HOT 1
- Unable to Display Elevation Chart in Angular Project with leaflet-elevation HOT 6
- {{track_info}} not always correctly build HOT 5
- Angular and leaflet-elevation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet-elevation.