webglearth / webglearth2-offline

Example of offline use of WebGL Earth 2 with tiles rendered by MapTiler
https://github.com/webglearth/webglearth2-offline/archive/gh-pages.zip
106 stars 44 forks source link

Is there a way to use webglearth2-offline with .js file versus .html? #9

Open chertik72 opened 4 years ago

chertik72 commented 4 years ago

I try to use it in .js component code with react as following: import React from 'react' import * as WE from 'webglearth2-offline-gh-pages/v2';

class FlightInfo extends React.Component {

componentDidMount() {
   this.initMap();
}

initMap() { // Offline tiles this.map = new WE.map('map'); this.map.setView([46.8011, 8.2266], 2); WE.tileLayer('{z}/{x}/{y}.jpg', { tileSize: 256, bounds: [[-85, -180], [85, 180]], minZoom: 0, maxZoom: 16, attribution: 'WebGLEarth example', tms: true }).addTo(this.map); }

render() { return(

    )

When I am trying to run with CALL npm run dev I am receiving module not found error:

./src/components/flightInfo/FlightInfo.js Module not found: Can't resolve 'webglearth2-offline-gh-pages/v2' in 'C:\heli-2020\tstWacs3Dbrancht\src\components\flightInfo'

Is there a way to resolve this error?