This file contains hidden or 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
| {results.length > 0 && | |
| this.renderTab( | |
| 'Map', | |
| MAP_TAB, | |
| 'fas fa-globe-americas', | |
| activeTab | |
| )} |
This file contains hidden or 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
| #map { | |
| width: auto; | |
| min-height: 350px; | |
| height: 40vmin; | |
| } |
This file contains hidden or 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
| import React, { Component } from 'react'; | |
| import L from 'leaflet'; | |
| // import Leaflet's CSS | |
| import 'leaflet/dist/leaflet.css'; | |
| import './ResultMap.css'; | |
| const redIcon = L.icon({ | |
| iconUrl: 'marker-icon-red.png', | |
| iconSize: [25, 41], // size of the icon | |
| iconAnchor: [12, 40], // point of the icon which will correspond to marker's location |
This file contains hidden or 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
| render() { | |
| return ( | |
| <div> | |
| <Header /> | |
| <div className="columns"> | |
| <div className="column is-one-third-desktop"> | |
| <GeocodingForm | |
| apikey={this.state.apikey} | |
| query={this.state.query} | |
| isSubmitting={this.state.isSubmitting} |
This file contains hidden or 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
| handleSubmit(event) { | |
| event.preventDefault(); | |
| this.setState({ isSubmitting: true }); | |
| opencage | |
| .geocode({ key: this.state.apikey, q: this.state.query }) | |
| .then(response => { | |
| console.log(response); | |
| this.setState({ response, isSubmitting: false }); | |
| }) | |
| .catch(err => { |
This file contains hidden or 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
| handleChange(key, value) { | |
| this.setState({ [key]: value }); | |
| } |
This file contains hidden or 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
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| query: '', | |
| apikey: '', | |
| isSubmitting: false, | |
| response: {}, | |
| }; | |
| this.handleSubmit = this.handleSubmit.bind(this); | |
| this.handleChange = this.handleChange.bind(this); |
This file contains hidden or 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
| import React, { Component } from 'react'; | |
| import Header from './Header'; | |
| import GeocodingForm from './GeocodingForm'; | |
| import GeocodingResults from './GeocodingResults'; | |
| import * as opencage from 'opencage-api-client'; |
This file contains hidden or 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
| // ./src/ResultJSON.js | |
| import React, { Component } from 'react'; | |
| import './ResultJSON.css'; | |
| class ResultJSON extends Component { | |
| render() { | |
| return ( | |
| <article className="message"> | |
| <div className="message-body"> | |
| <pre>{JSON.stringify(this.props.response, null, 2)}</pre> | |
| </div> |
This file contains hidden or 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
| // ./src/ResultList.js | |
| import React, { Component } from 'react'; | |
| class ResultList extends Component { | |
| render() { | |
| const rate = this.props.response.rate || {}; | |
| const results = this.props.response.results || []; | |
| return ( | |
| <article className="message"> | |
| <div className="message-body"> | |
| <ol> |