Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diff with Deck and without DeckGL with XYZ IMLProvider #7

Open
wants to merge 1 commit into
base: feature/IMLProviderWithDeckOverlay
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

<div id="container">
Map Canvas: <div id="map-canvas"></div>
Deck Canvas: <canvas id="deck-canvas"></canvas>


</div>

<!-- <script type="module" src="src/index.js"></script> -->
Expand Down
51 changes: 3 additions & 48 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { style } from "./style";

const INITIAL_VIEW_STATE = {
longitude: -120.64021673968094, //-73.75,
latitude: 38.19311064138663, //40.73,
zoom: 6.3,
latitude: 36.19311064138663, //40.73,
zoom: 7.3,
bearing: 0,
pitch: 0,

Expand All @@ -33,23 +33,6 @@ const INITIAL_VIEW_STATE = {
maxPitch: 50,
};

// Setup Deck GL
const deckgl = new Deck({
// layers: layersWorldAirports,
// layerHeatMap,
// layerScatterplot,
canvas: "deck-canvas",
width: "100%",
height: "100%",
initialViewState: INITIAL_VIEW_STATE,
controller: true,
style: { zIndex: "auto" },
views: new MapView({
repeat: true,
}),
debug: true,
});

/** setup the XYZ map and "basemap" layer **/
const baseMapLayer = new MVTLayer({
name: "mvt-world-layer",
Expand Down Expand Up @@ -77,7 +60,7 @@ var imlLayer = new TileLayer({
max: 20,
// create the SpaceProvider
provider: new IMLProvider({
level: 10,
level: 3,
layer: layerId,
catalog: catalogHrn,
credentials: {
Expand Down Expand Up @@ -109,33 +92,5 @@ const map = new Map(document.getElementById("map-canvas"), {
rotate: 0,
});

/**
* @map - { Map } from "@here/xyz-maps-display"
* viewState : {
latitude: number,
longitude: number,
zoom: number,
bearing: number,
pitch: number,
};
*/
const updateMapCamera = (map, viewState) => {
// Set the view state's lon/lat to ones mapping with XYZ Maps
map.setCenter(viewState.longitude, viewState.latitude);

// XYZ Maps roatation is negative of DeckGL
map.rotate(viewState.bearing * -1);
map.pitch(viewState.pitch);

// Center of XYZ Maps is one level higher than deck's zoom level
map.setZoomlevel(viewState.zoom + 1);
};

deckgl.setProps({
onViewStateChange: ({ viewState }) => updateMapCamera(map, viewState, deckgl),
onResize: ({ width, height }) => map.resize(width, height),
});

// optionally add renderers to window object
window.xyzmap = map;
window.deckoverlay = deckgl;