DELETEDGetting started: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
(Created page with "This is where we help you get started")
 
No edit summary
Line 1: Line 1:
This is where we help you get started
Maria web map components can be used as standard Web Components, and as React components.
An access token from Teleplan is needed to access these NPM-packages. The access token can be placed in a local .npmrc file in the root of the project using the packages.<br>
 
Example .npmrc:
<source lang="Bash">
//registry.npmjs.org/:_authToken=YOUR_ACCESS_TOKEN
</source>
== Web Components ==
To install the Web Component packages, install the following NPM-packages.
<source lang="Bash">
npm i @mariateleplan/map-core @mariateleplan/map-components
</source>
 
== React Components ==
To install the Web Component packages, install the following NPM-packages.
<source lang="Bash">
npm i @mariateleplan/map-core @mariateleplan/map-react-components
</source>
 
=== Minimal React Example ===
<source lang="javascript">
 
import { MariaMap, MapLayerSelect } from '@mariateleplan/map-react-components';
import { Maria as MariaCore} from '@mariateleplan/map-core/dist/Maria';
import {  GDKMapLayer } from '@mariateleplan/map-core/dist/layers';
 
 
 
let maria=new MariaCore({
  "viewState": {
    "zoom": 10,
    "center": [1197567, 8380058], // Oslo
    "projection": 'EPSG:3857'
  },
  "layersState": {
  }
});
 
 
function addMapLayers():void{
 
  const mariaMapLayer = new GDKMapLayer({
    Id:"0b254a7a-ff92-4b98-b6a2-1cfb8d91e9f1",
    Name:"GDK Imagery",
    ServiceUrl:new URL("http://tpg-mariagdktst"),
    BasemapId:"0b254a7a-ff92-4b98-b6a2-1cfb8d91e9f1"
  });
 
  maria.Layer.addLayer(mariaMapLayer);
}
 
function App() {
 
  useEffect(() => {
      addMapLayers();
  }, [])
 
  return (
      <MariaMap MariaApi={maria}>
        <MapLayerSelect></MapLayerSelect>
      </MariaMap>
  );
}
export default App;
 
</source>

Revision as of 13:24, 14 October 2021

Maria web map components can be used as standard Web Components, and as React components. An access token from Teleplan is needed to access these NPM-packages. The access token can be placed in a local .npmrc file in the root of the project using the packages.

Example .npmrc:

//registry.npmjs.org/:_authToken=YOUR_ACCESS_TOKEN

Web Components

To install the Web Component packages, install the following NPM-packages.

npm i @mariateleplan/map-core @mariateleplan/map-components

React Components

To install the Web Component packages, install the following NPM-packages.

npm i @mariateleplan/map-core @mariateleplan/map-react-components

Minimal React Example

import { MariaMap, MapLayerSelect } from '@mariateleplan/map-react-components';
import { Maria as MariaCore} from '@mariateleplan/map-core/dist/Maria';
import {  GDKMapLayer } from '@mariateleplan/map-core/dist/layers';



let maria=new MariaCore({
  "viewState": {
    "zoom": 10,
    "center": [1197567, 8380058], // Oslo
    "projection": 'EPSG:3857'
  },
  "layersState": {
  }
});


function addMapLayers():void{

  const mariaMapLayer = new GDKMapLayer({
    Id:"0b254a7a-ff92-4b98-b6a2-1cfb8d91e9f1",
    Name:"GDK Imagery",
    ServiceUrl:new URL("http://tpg-mariagdktst"), 
    BasemapId:"0b254a7a-ff92-4b98-b6a2-1cfb8d91e9f1"
  });

  maria.Layer.addLayer(mariaMapLayer); 
}

function App() {
  
  useEffect(() => {
      addMapLayers();
  }, [])

  return (
      <MariaMap MariaApi={maria}>
        <MapLayerSelect></MapLayerSelect>
      </MariaMap>
  );
}
export default App;