Skip to content

Commit

Permalink
examples: Use maplibre export from react-map-gl (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
birkskyum authored May 2, 2024
1 parent 470e69b commit f23e7eb
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 32 deletions.
4 changes: 1 addition & 3 deletions examples/editable-layers/advanced/src/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import * as React from 'react';
import DeckGL from '@deck.gl/react';
import {MapView, MapController} from '@deck.gl/core';
import StaticMap from 'react-map-gl';
import StaticMap from 'react-map-gl/maplibre';
import {GL} from '@luma.gl/constants';
import circle from '@turf/circle';
import MapLibre from 'maplibre-gl';

import {
EditableGeoJsonLayer,
Expand Down Expand Up @@ -829,7 +828,6 @@ export default class Example extends React.Component<
renderStaticMap(viewport: Record<string, any>) {
return (
<StaticMap
mapLib={MapLibre}
{...viewport}
mapStyle={'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'}
/>
Expand Down
5 changes: 2 additions & 3 deletions examples/editable-layers/codesandbox/getting-started/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import DeckGL from '@deck.gl/react';
// TODO Enable eslint after package is published.
// eslint-disable-next-line import/named, import/no-extraneous-dependencies
import {HtmlOverlayItem, HtmlClusterOverlay} from '@deck.gl-community/react';
import StaticMap from 'react-map-gl';
import MapLibre from 'maplibre-gl';
import StaticMap from 'react-map-gl/maplibre';

const DATA_URL = 'https://cors-tube.vercel.app/?url=https://whc.unesco.org/en/list/georss/';

Expand Down Expand Up @@ -117,7 +116,7 @@ export class WorldHeritageApp extends React.Component {
render() {
return (
<DeckGL initialViewState={initialViewState} controller={true}>
<StaticMap mapLib={MapLibre} />
<StaticMap />
{this.renderWorldHeritage()}
</DeckGL>
);
Expand Down
5 changes: 2 additions & 3 deletions examples/editable-layers/codesandbox/world-heritage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import DeckGL from '@deck.gl/react';
// TODO Enable eslint after package is published.
// eslint-disable-next-line import/named
import {HtmlOverlayItem, HtmlClusterOverlay} from '@deck.gl-community/react';
import {StaticMap} from 'react-map-gl';
import MapLibre from 'maplibre-gl';
import {StaticMap} from 'react-map-gl/maplibre';

const DATA_URL = 'https://cors-tube.vercel.app/?url=https://whc.unesco.org/en/list/georss/';

Expand Down Expand Up @@ -117,7 +116,7 @@ export class WorldHeritageApp extends React.Component {
render() {
return (
<DeckGL initialViewState={initialViewState} controller={true}>
<StaticMap mapLib={MapLibre} />
<StaticMap />
{this.renderWorldHeritage()}
</DeckGL>
);
Expand Down
8 changes: 2 additions & 6 deletions examples/editable-layers/editable-h3-cluster-layer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import {
DrawCircleFromCenterMode,
DrawRectangleMode
} from '@deck.gl-community/editable-layers';
import StaticMap from 'react-map-gl';
import StaticMap from 'react-map-gl/maplibre';
import {hexagonCluster1, hexagonCluster2, hexagonCluster3} from './data';
import MapLibre from 'maplibre-gl';

const SELECTED_FILL_COLOR = [50, 100, 200, 230];
const UNSELECTED_FILL_COLOR = [50, 100, 200, 100];
Expand Down Expand Up @@ -195,10 +194,7 @@ export function Example() {
layers={[layer]}
getCursor={layer.getCursor.bind(layer)}
>
<StaticMap
mapLib={MapLibre}
mapStyle={'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'}
/>
<StaticMap mapStyle={'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'} />
</DeckGL>
<Toolbar
{...{
Expand Down
8 changes: 2 additions & 6 deletions examples/editable-layers/editor/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React, {useState} from 'react';
import DeckGL from '@deck.gl/react';
import {ViewMode, EditableGeoJsonLayer} from '@deck.gl-community/editable-layers';
import {Toolbox} from '@deck.gl-community/react-editable-layers';
import StaticMap from 'react-map-gl';
import MapLibre from 'maplibre-gl';
import StaticMap from 'react-map-gl/maplibre';

const initialViewState = {
longitude: -122.43,
Expand Down Expand Up @@ -81,10 +80,7 @@ export function Example() {
}
}}
>
<StaticMap
mapLib={MapLibre}
mapStyle={'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'}
/>
<StaticMap mapStyle={'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'} />
</DeckGL>

<Toolbox
Expand Down
8 changes: 2 additions & 6 deletions examples/editable-layers/overlays/example.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, {useEffect, useState} from 'react';
import DeckGL from '@deck.gl/react';
import StaticMap from 'react-map-gl';
import StaticMap from 'react-map-gl/maplibre';
import {INITIAL_COORDS, INITIAL_VIEW_STATE} from './constants';
import {HtmlOverlay, HtmlOverlayItem} from '@deck.gl-community/react';
import type {WikipediaEntry} from './types';
import MapLibre from 'maplibre-gl';

const styles = {
mapContainer: {
Expand Down Expand Up @@ -59,10 +58,7 @@ const Example = () => {
return (
<div style={styles.mapContainer}>
<DeckGL initialViewState={INITIAL_VIEW_STATE} controller={true}>
<StaticMap
mapLib={MapLibre}
mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"
/>
<StaticMap mapStyle="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json" />
{data ? (
<HtmlOverlay>
{data.map((feature) => (
Expand Down
4 changes: 1 addition & 3 deletions examples/editable-layers/sf/example.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as React from 'react';
import StaticMap from 'react-map-gl';
import StaticMap from 'react-map-gl/maplibre';
import CSS from 'csstype';

import DeckGL from '@deck.gl/react';
import {WebMercatorViewport} from '@deck.gl/core';
import {TextLayer} from '@deck.gl/layers';
import MapLibre from 'maplibre-gl';

import {
NebulaCore,
Expand Down Expand Up @@ -309,7 +308,6 @@ export default class Example extends React.Component<
<div style={mapContainerStyle}>
<link href="https://unpkg.com/maplibre-gl@^4.1.3/dist/maplibre-gl.css" rel="stylesheet" />
<StaticMap
mapLib={MapLibre}
{...viewState}
mapStyle={'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json'}
>
Expand Down
3 changes: 1 addition & 2 deletions website/src/doc-demos/demo-base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import DeckGL from '@deck.gl/react';
import {Map} from 'react-map-gl';
import {Map} from 'react-map-gl/maplibre';
import styled from 'styled-components';
import {useColorMode} from '@docusaurus/theme-common';
import {MAPBOX_STYLES} from '../constants/defaults';
Expand Down Expand Up @@ -129,7 +129,6 @@ export function makeLayerDemo(config) {
{mapStyle && (
<Map
reuseMaps
mapLib={import('maplibre-gl')}
mapStyle={mapStyleSheet}
preventStyleDiffing={true}
/>
Expand Down

0 comments on commit f23e7eb

Please sign in to comment.