|
@@ -0,0 +1,65 @@
|
|
|
+import React from "react";
|
|
|
+import Map from 'pigeon-maps'
|
|
|
+import Marker from 'pigeon-marker'
|
|
|
+import Overlay from 'pigeon-overlay'
|
|
|
+
|
|
|
+export default class Pigeon extends React.Component{
|
|
|
+
|
|
|
+ constructor(props) {
|
|
|
+ super(props)
|
|
|
+
|
|
|
+ this.state = {
|
|
|
+ zoom: 15
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ providers = {
|
|
|
+ osm: (x, y, z) => {
|
|
|
+ // use 3 urls to download the tiles faster
|
|
|
+ const s = String.fromCharCode(97 + ((x + y + z) % 3))
|
|
|
+ return `https://${s}.tile.openstreetmap.org/${z}/${x}/${y}.png`
|
|
|
+ },
|
|
|
+ stamenTerrain: (x, y, z, dpr) => {
|
|
|
+ return `https://stamen-tiles.a.ssl.fastly.net/terrain/${z}/${x}/${y}${dpr >= 2 ? '@2x' : ''}.jpg`
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ zoomIn = () => {
|
|
|
+ this.setState({
|
|
|
+ zoom: Math.min(this.state.zoom + 1, 22),
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ zoomOut = () => {
|
|
|
+ this.setState({
|
|
|
+ zoom: Math.max(this.state.zoom - 1, 0),
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ render(){
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div>
|
|
|
+ <Map
|
|
|
+ center={[48.336950, 14.320570]}
|
|
|
+ defaultZoom={15}
|
|
|
+ zoom={this.state.zoom}
|
|
|
+ width={600}
|
|
|
+ height={400}
|
|
|
+ attribution="Pigeon Map"
|
|
|
+ attributionPrefix={false}
|
|
|
+ animation={true}
|
|
|
+ provider={this.providers["osm"]}>
|
|
|
+ {/* animation: for example when switching between different markers */}
|
|
|
+ <Marker anchor={[48.336950, 14.320570]} payload={1} onClick={({ event, anchor, payload }) => {}} />
|
|
|
+
|
|
|
+ <Overlay anchor={[48.337069, 14.319570]} offset={[120, 79]}>
|
|
|
+ {/*<img src='pigeon.png' width={240} height={158} alt='pigeon' />*/}
|
|
|
+ </Overlay>
|
|
|
+ </Map>
|
|
|
+ <button onClick={this.zoomIn}>+</button>
|
|
|
+ <button onClick={this.zoomOut}>-</button>
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|