-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd602b0
commit 8e12eb4
Showing
4 changed files
with
613 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
This demonstrates the usage of the WfsSearch. | ||
|
||
```jsx | ||
const React = require('react'); | ||
const OlMap = require('ol/map').default; | ||
const OlView = require('ol/view').default; | ||
const OlLayerTile = require('ol/layer/tile').default; | ||
const OlSourceOsm = require('ol/source/osm').default; | ||
const OlProj = require('ol/proj').default; | ||
|
||
class WfsSearchExample extends React.Component { | ||
|
||
constructor(props) { | ||
|
||
super(props); | ||
|
||
this.mapDivId = `map-${Math.random()}`; | ||
|
||
this.map = new OlMap({ | ||
layers: [ | ||
new OlLayerTile({ | ||
name: 'OSM', | ||
source: new OlSourceOsm() | ||
}) | ||
], | ||
view: new OlView({ | ||
center: OlProj.fromLonLat([37.40570, 8.81566]), | ||
zoom: 4 | ||
}) | ||
}); | ||
} | ||
|
||
componentDidMount() { | ||
this.map.setTarget(this.mapDivId); | ||
} | ||
|
||
render() { | ||
return( | ||
<div> | ||
<div className="example-block"> | ||
<label>WFS Search:<br /> | ||
<WfsSearch | ||
placeholder="Type a countryname in its own language…" | ||
baseUrl='http://ows.terrestris.de/geoserver/osm/wfs' | ||
featureTypes={['osm:osm-country-borders']} | ||
searchAttributes={['name']} | ||
map={this.map} | ||
style={{ | ||
width: '80%' | ||
}} | ||
/> | ||
</label> | ||
</div> | ||
<div | ||
id={this.mapDivId} | ||
style={{ | ||
height: '400px' | ||
}} | ||
/> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
<WfsSearchExample /> | ||
``` |
Oops, something went wrong.