NominatimSearch example

This demonstrates the usage of the NominatimSearch.

    import React from 'react';
import { render } from 'react-dom';
import { NominatimSearch } from '@terrestris/react-geo';

import OlMap from 'ol/map';
import OlView from 'ol/view';
import OlLayerTile from 'ol/layer/tile';
import OlSourceOsm from 'ol/source/osm';
import olProj from 'ol/proj';

//
// ***************************** SETUP *****************************************
//
const map = new OlMap({
  layers: [
    new OlLayerTile({
      name: 'OSM',
      source: new OlSourceOsm()
    })
  ],
  view: new OlView({
    center: olProj.fromLonLat([37.40570, 8.81566]),
    zoom: 4
  })
});

//
// ***************************** SETUP END *************************************
//

render(
  <div>
    <div className="example-block">
      <label>The NominatimSearch<br />
        <NominatimSearch map={map} style={{
          width: '80%'
        }} />
      </label>
    </div>
    <div id="map" style={{
      height: '400px'
    }} />
  </div>,

  // Target
  document.getElementById('exampleContainer'),

  // Callback
  () => {
    map.setTarget('map');
  }
);