Skip to content

Commit

Permalink
HARP-12299 Numerous fixes:
Browse files Browse the repository at this point in the history
- Removed links to unpkg / cloudfare and pack resources instead
- Fix broken example_simplejs example
- Fix rollup export
- use setTheme instead of ThemeLoader
- fixed example_simplejs.ts

Signed-off-by: Jonathan Stichbury <[email protected]>
  • Loading branch information
nzjony committed Nov 6, 2020
1 parent a9d01de commit a81626c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 45 deletions.
12 changes: 3 additions & 9 deletions examples/choropleth.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
<head>
<meta charset="utf-8" />
<title></title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.css"
/>
<link rel="stylesheet" href="./vendor/leaflet.css" />
<style>
html,
body {
Expand Down Expand Up @@ -46,11 +43,8 @@
</head>
<body>
<div id="map" style="height: 100%;"></div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/leaflet.js"
charset="utf-8"
></script>
<script src="https://unpkg.com/[email protected]/build/three.min.js" charset="utf-8"></script>
<script src="./vendor/leaflet.js" charset="utf-8"></script>
<script src="./vendor/three.min.js" charset="utf-8"></script>
<script src="./build/example_choropleth.bundle.js" charset="utf-8"></script>
</body>
</html>
12 changes: 3 additions & 9 deletions examples/helloworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
<head>
<meta charset="utf-8" />
<title></title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.6.0/leaflet.css"
/>
<link rel="stylesheet" href="./vendor/leaflet.css" />
<style>
html,
body {
Expand Down Expand Up @@ -201,11 +198,8 @@ <h2 class="harp-gl-header">Location</h2>
</div>
</div>

<script
src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.6.0/leaflet.js"
charset="utf-8"
></script>
<script src="https://unpkg.com/[email protected]/build/three.min.js" charset="utf-8"></script>
<script src="./vendor/leaflet.js" charset="utf-8"></script>
<script src="./vendor/three.min.js" charset="utf-8"></script>
<script src="./build/example_basic.bundle.js" charset="utf-8"></script>
</body>
</html>
12 changes: 3 additions & 9 deletions examples/simplejs-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
<head>
<meta charset="utf-8" />
<title></title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.6.0/leaflet.css"
/>
<link rel="stylesheet" href="vendor/leaflet.css" />
<style>
html,
body {
Expand All @@ -18,11 +15,8 @@
</head>
<body>
<div id="map" style="height: 100%;"></div>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.0/leaflet.js"
charset="utf-8"
></script>
<script src="https://unpkg.com/[email protected]/build/three.min.js" charset="utf-8"></script>
<script src="./vendor/leaflet.js" charset="utf-8"></script>
<script src="./vendor/three.min.js" charset="utf-8"></script>
<script src="./vendor/harp.min.js"></script>
<script src="./vendor/harp-leaflet.js"></script>
<script src="./build/example_simplejs.bundle.js" charset="utf-8"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/src/decoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declare let self: Worker & {
importScripts(..._scripts: string[]): void;
};

self.importScripts("https://unpkg.com/[email protected]/build/three.min.js");
self.importScripts("../vendor/three.min.js");

import { OmvTileDecoderService, OmvTilerService } from "@here/harp-omv-datasource/index-worker";

Expand Down
3 changes: 1 addition & 2 deletions examples/src/example_basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { ThemeLoader } from "@here/harp-mapview";
import { APIFormat, AuthenticationMethod, OmvDataSource } from "@here/harp-omv-datasource";
import { HarpGL } from "harp-leaflet";
import * as L from "leaflet";
Expand Down Expand Up @@ -67,7 +66,7 @@ installButtonGroupHandler(
{
default: "theme-berlin-base",
onChange: async (themeUri) => {
harpGL.mapView.theme = await ThemeLoader.load(themeUri);
harpGL.mapView.setTheme(themeUri);
},
}
);
Expand Down
21 changes: 8 additions & 13 deletions examples/src/example_simplejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,27 @@
* Licensed under Apache 2.0, see full license in LICENSE
* SPDX-License-Identifier: Apache-2.0
*/
import { APIFormat, OmvDataSource } from "@here/harp-omv-datasource";
import { HarpGL } from "harp-leaflet";
import L from "leaflet";
import * as config from "./config";

interface ILeafletExtended {
HarpGL: any;
}

// @ts-ignore
const LE: typeof L & ILeafletExtended = L as any;
declare let harp: typeof import("@here/harp-omv-datasource") & typeof import("@here/harp-geoutils");

const map = LE.map("map", {
const map = L.map("map", {
// wheelDebounceTime: 10
}).setView([38.912753, -77.032194], 15);

LE.marker([38.912753, -77.032194])
L.marker([38.912753, -77.032194])
.bindPopup("Hello <b>Harp GL</b>!<br>Whoa, it works!")
.addTo(map)
.openPopup();

const harpGL = new LE.HarpGL({
const harpGL = new HarpGL({
theme: "resources/harp-map-theme/berlin_tilezen_night_reduced.json",
}).addTo(map);

const dataSource = new harp.OmvDataSource({
const dataSource = new OmvDataSource({
baseUrl: "https://xyz.api.here.com/tiles/osmbase/512/all",
apiFormat: harp.APIFormat.XYZMVT,
apiFormat: APIFormat.XYZMVT,
styleSetName: config.styleSetName,
maxZoomLevel: 17,
authenticationCode: config.accessToken,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@here/harp-leaflet",
"version": "0.2.4",
"version": "0.2.5",
"description": "Leaflet plugin for harp.gl maps",
"author": {
"name": "HERE Europe B.V.",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
"@here/harp-omv-datasource": "harp",
},
file: "./build/harp-leaflet.js",
name: "L.HarpGL",
name: "HarpGL",
format: "umd",
},
};
9 changes: 9 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const entries = glob.sync("./examples/src/*.ts").reduce(
);

const harpMapThemePath = path.dirname(require.resolve("@here/harp-map-theme/package.json"));
const leafletDist = path.dirname(require.resolve("leaflet/dist/leaflet.js"));

module.exports = {
context: dir,
Expand Down Expand Up @@ -52,11 +53,19 @@ module.exports = {
from: require.resolve("@here/harp.gl/dist/harp-decoders.min.js"),
to: "vendor/",
},
{
from: require.resolve("three/build/three.min.js"),
to: "vendor/",
},
{
from: path.join(harpMapThemePath, "resources/"),
to: "resources/harp-map-theme",
toType: "dir",
},
{
from: leafletDist,
to: "vendor/",
},
]),
],
devServer: {
Expand Down

0 comments on commit a81626c

Please sign in to comment.