-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from go-spatial/jump-to-location
jump to location functionality
- Loading branch information
Showing
9 changed files
with
207 additions
and
84 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
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
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
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
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 |
---|---|---|
@@ -1,55 +1,58 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import Icon from '../Icon' | ||
import Tooltip from '../Tooltip' | ||
|
||
export default class MapMapboxControls extends React.Component { | ||
static propTypes = { | ||
map:PropTypes.object | ||
} | ||
class MapMapboxControls extends React.Component { | ||
|
||
constructor (props){ | ||
super(props) | ||
const {map} = props | ||
|
||
this.state = { | ||
debugLines:false | ||
} | ||
|
||
this.handle = { | ||
debugLinesToggle:()=>{ | ||
if (this.state.debugLines){ | ||
this.setState({debugLines:false}) | ||
map.showTileBoundaries = false | ||
} else { | ||
this.setState({debugLines:true}) | ||
map.showTileBoundaries = true | ||
} | ||
} | ||
} | ||
|
||
for (let i in this.handle){ | ||
this.handle[i] = this.handle[i].bind(this) | ||
debugLines:false, | ||
} | ||
} | ||
|
||
componentDidMount(){ | ||
this.tooltip() | ||
} | ||
handleDebugLinesToggle = ()=>{ | ||
const {map} = this.props, | ||
{debugLines} = this.state | ||
|
||
tooltip(){ | ||
//console.log('ref:',) | ||
//window.$(this.tooltipsRef).children().tooltip() | ||
if (debugLines){ | ||
this.setState({debugLines:false}) | ||
map.showTileBoundaries = false | ||
} else { | ||
this.setState({debugLines:true}) | ||
map.showTileBoundaries = true | ||
} | ||
} | ||
|
||
render (){ | ||
|
||
const className = 'mapboxgl-ctrl-icon'+(this.state.debugLines? ' active': '') | ||
|
||
return <div className="mapboxgl-ctrl mapboxgl-ctrl-group" ref={ref => this.tooltipsRef = ref}> | ||
<button className={className} onClick={this.handle.debugLinesToggle} title="debug lines"> | ||
<Icon icon={'debug-lines'}/> | ||
</button> | ||
</div> | ||
const {handleLocationToggle} = this.props, | ||
{debugLines} = this.state | ||
|
||
return ( | ||
<React.Fragment> | ||
<div className="mapboxgl-ctrl mapboxgl-ctrl-group tooltip-trigger"> | ||
<button className={`mapboxgl-ctrl-icon`} onClick={handleLocationToggle}> | ||
<Icon icon={'location'}/> | ||
</button> | ||
<Tooltip direction={'left'} message={'jump to location'} origin={'left'}/> | ||
</div> | ||
<div className="mapboxgl-ctrl mapboxgl-ctrl-group tooltip-trigger"> | ||
<button className={`mapboxgl-ctrl-icon ${debugLines? 'active': ''}`} onClick={this.handleDebugLinesToggle}> | ||
<Icon icon={'debug-lines'}/> | ||
</button> | ||
<Tooltip direction={'left'} message={`debug lines ${debugLines? 'off': 'on'}`} origin={'left'}/> | ||
</div> | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
} | ||
|
||
MapMapboxControls.propTypes = { | ||
handleLocationToggle: PropTypes.func, | ||
map:PropTypes.object, | ||
} | ||
|
||
export default MapMapboxControls |
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,53 @@ | ||
const locations = [{ | ||
"key":"sd", | ||
"label":"San Diego", | ||
"lat":32.72, | ||
"lng":-117.15, | ||
"zoom":11 | ||
},{ | ||
"key":"la", | ||
"label":"Los Angeles", | ||
"lat":34.04, | ||
"lng":-118.31, | ||
"zoom":11 | ||
},{ | ||
"key":"sf", | ||
"label":"San Francisco", | ||
"lat":37.77, | ||
"lng":-122.40, | ||
"zoom":11 | ||
},{ | ||
"key":"ny", | ||
"label":"New York", | ||
"lat":40.74, | ||
"lng":-74.0, | ||
"zoom":11 | ||
},{ | ||
"key":"dc", | ||
"label":"Washington, DC", | ||
"lat":38.88, | ||
"lng":-77.04, | ||
"zoom":11 | ||
},{ | ||
"key":"bs", | ||
"label":"Boston", | ||
"lat":42.36, | ||
"lng":-71.05, | ||
"zoom":11 | ||
},{ | ||
"key":"br", | ||
"label":"Berlin", | ||
"lat":52.51, | ||
"lng":13.36, | ||
"zoom":11 | ||
},{ | ||
"key":"tk", | ||
"label":"Tokyo", | ||
"lat":35.69, | ||
"lng":139.73, | ||
"zoom":11 | ||
}] | ||
|
||
export default { | ||
locations, | ||
} |
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
Oops, something went wrong.