From e13e630cd6e4fc0b1ff92098a28a770794c7bb9a Mon Sep 17 00:00:00 2001 From: gabrhr <73925454+gabrhr@users.noreply.github.com> Date: Wed, 20 Apr 2022 10:19:29 -0500 Subject: =?UTF-8?q?A=C3=B1adir=20plantilla?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Base para front --- front/odiparpack/app/containers/Maps/Info.js | 18 ++++ .../odiparpack/app/containers/Maps/MapDirection.js | 33 ++++++ front/odiparpack/app/containers/Maps/MapMarker.js | 38 +++++++ front/odiparpack/app/containers/Maps/SearchMap.js | 33 ++++++ .../app/containers/Maps/StreetViewMap.js | 33 ++++++ .../app/containers/Maps/TrafficIndicator.js | 33 ++++++ .../app/containers/Maps/demos/BasicMarker.js | 38 +++++++ .../app/containers/Maps/demos/Direction.js | 56 ++++++++++ .../app/containers/Maps/demos/PopoverMarker.js | 55 ++++++++++ .../app/containers/Maps/demos/SearchLocation.js | 116 +++++++++++++++++++++ .../app/containers/Maps/demos/StreetView.js | 62 +++++++++++ .../app/containers/Maps/demos/Traffic.js | 37 +++++++ .../odiparpack/app/containers/Maps/demos/index.js | 6 ++ 13 files changed, 558 insertions(+) create mode 100644 front/odiparpack/app/containers/Maps/Info.js create mode 100644 front/odiparpack/app/containers/Maps/MapDirection.js create mode 100644 front/odiparpack/app/containers/Maps/MapMarker.js create mode 100644 front/odiparpack/app/containers/Maps/SearchMap.js create mode 100644 front/odiparpack/app/containers/Maps/StreetViewMap.js create mode 100644 front/odiparpack/app/containers/Maps/TrafficIndicator.js create mode 100644 front/odiparpack/app/containers/Maps/demos/BasicMarker.js create mode 100644 front/odiparpack/app/containers/Maps/demos/Direction.js create mode 100644 front/odiparpack/app/containers/Maps/demos/PopoverMarker.js create mode 100644 front/odiparpack/app/containers/Maps/demos/SearchLocation.js create mode 100644 front/odiparpack/app/containers/Maps/demos/StreetView.js create mode 100644 front/odiparpack/app/containers/Maps/demos/Traffic.js create mode 100644 front/odiparpack/app/containers/Maps/demos/index.js (limited to 'front/odiparpack/app/containers/Maps') diff --git a/front/odiparpack/app/containers/Maps/Info.js b/front/odiparpack/app/containers/Maps/Info.js new file mode 100644 index 0000000..1faea09 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/Info.js @@ -0,0 +1,18 @@ +import React from 'react'; +import Type from 'ba-styles/Typography.scss'; +import { Typography } from '@material-ui/core'; + +class Info extends React.Component { + render() { + return ( + + This demo may not working properly because it has not added Google Map api key. To add Your own Google Map api key please follow this link +   + {' '} + https://developers.google.com/maps/documentation/javascript/get-api-key + + ); + } +} + +export default Info; diff --git a/front/odiparpack/app/containers/Maps/MapDirection.js b/front/odiparpack/app/containers/Maps/MapDirection.js new file mode 100644 index 0000000..97a463b --- /dev/null +++ b/front/odiparpack/app/containers/Maps/MapDirection.js @@ -0,0 +1,33 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; +import brand from 'ba-api/brand'; +import { SourceReader, PapperBlock } from 'ba-components'; +import { Direction } from './demos'; +import Info from './Info'; + +class MapDirection extends React.Component { + render() { + const title = brand.name + ' - Map'; + const description = brand.desc; + const docSrc = 'containers/Maps/demos/'; + return ( +
+ + {title} + + + + + + + + + + + +
+ ); + } +} + +export default MapDirection; diff --git a/front/odiparpack/app/containers/Maps/MapMarker.js b/front/odiparpack/app/containers/Maps/MapMarker.js new file mode 100644 index 0000000..65f2420 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/MapMarker.js @@ -0,0 +1,38 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; +import brand from 'ba-api/brand'; +import { SourceReader, PapperBlock } from 'ba-components'; +import { BasicMarker, PopoverMarker } from './demos'; +import Info from './Info'; + +class MapMarker extends React.Component { + render() { + const title = brand.name + ' - Map'; + const description = brand.desc; + const docSrc = 'containers/Maps/demos/'; + return ( +
+ + {title} + + + + + + + + + + + + + + + + +
+ ); + } +} + +export default MapMarker; diff --git a/front/odiparpack/app/containers/Maps/SearchMap.js b/front/odiparpack/app/containers/Maps/SearchMap.js new file mode 100644 index 0000000..b3e21d9 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/SearchMap.js @@ -0,0 +1,33 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; +import brand from 'ba-api/brand'; +import { SourceReader, PapperBlock } from 'ba-components'; +import { SearchLocation } from './demos'; +import Info from './Info'; + +class SearchMap extends React.Component { + render() { + const title = brand.name + ' - Map'; + const description = brand.desc; + const docSrc = 'containers/Maps/demos/'; + return ( +
+ + {title} + + + + + + + + + + + +
+ ); + } +} + +export default SearchMap; diff --git a/front/odiparpack/app/containers/Maps/StreetViewMap.js b/front/odiparpack/app/containers/Maps/StreetViewMap.js new file mode 100644 index 0000000..e307da8 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/StreetViewMap.js @@ -0,0 +1,33 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; +import brand from 'ba-api/brand'; +import { SourceReader, PapperBlock } from 'ba-components'; +import { StreetView } from './demos'; +import Info from './Info'; + +class StreetViewMap extends React.Component { + render() { + const title = brand.name + ' - Map'; + const description = brand.desc; + const docSrc = 'containers/Maps/demos/'; + return ( +
+ + {title} + + + + + + + + + + + +
+ ); + } +} + +export default StreetViewMap; diff --git a/front/odiparpack/app/containers/Maps/TrafficIndicator.js b/front/odiparpack/app/containers/Maps/TrafficIndicator.js new file mode 100644 index 0000000..e1e8a69 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/TrafficIndicator.js @@ -0,0 +1,33 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; +import brand from 'ba-api/brand'; +import { SourceReader, PapperBlock } from 'ba-components'; +import { Traffic } from './demos'; +import Info from './Info'; + +class TrafficIndicator extends React.Component { + render() { + const title = brand.name + ' - Map'; + const description = brand.desc; + const docSrc = 'containers/Maps/demos/'; + return ( +
+ + {title} + + + + + + + + + + + +
+ ); + } +} + +export default TrafficIndicator; diff --git a/front/odiparpack/app/containers/Maps/demos/BasicMarker.js b/front/odiparpack/app/containers/Maps/demos/BasicMarker.js new file mode 100644 index 0000000..7577923 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/demos/BasicMarker.js @@ -0,0 +1,38 @@ +import React from 'react'; +import { compose } from 'recompose'; +import { + withScriptjs, + withGoogleMap, + GoogleMap, + Marker, +} from 'react-google-maps'; + +const MapWithAMarker = compose( + withScriptjs, + withGoogleMap +)(props => ( + + + +)); + +class BasicMarker extends React.Component { + render() { + return ( + } + containerElement={
} + mapElement={
} + /> + ); + } +} + +export default BasicMarker; diff --git a/front/odiparpack/app/containers/Maps/demos/Direction.js b/front/odiparpack/app/containers/Maps/demos/Direction.js new file mode 100644 index 0000000..8867466 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/demos/Direction.js @@ -0,0 +1,56 @@ +/* eslint-disable no-undef */ +import React from 'react'; +import { compose, withProps, lifecycle } from 'recompose'; +import { + withScriptjs, + withGoogleMap, + GoogleMap, + DirectionsRenderer, +} from 'react-google-maps'; + +const MapWithADirectionsRenderer = compose( + withProps({ + googleMapURL: 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places', + loadingElement:
, + containerElement:
, + mapElement:
, + }), + withScriptjs, + withGoogleMap, + lifecycle({ + componentDidMount() { + const DirectionsService = new google.maps.DirectionsService(); + + DirectionsService.route({ + origin: new google.maps.LatLng(41.8507300, -87.6512600), + destination: new google.maps.LatLng(41.8525800, -87.6514100), + travelMode: google.maps.TravelMode.DRIVING, + }, (result, status) => { + if (status === google.maps.DirectionsStatus.OK) { + this.setState({ + directions: result, + }); + } else { + console.error(`error fetching directions ${result}`); + } + }); + } + }) +)(props => ( + + {props.directions && } + +)); + +class Direction extends React.Component { + render() { + return ( + + ); + } +} + +export default Direction; diff --git a/front/odiparpack/app/containers/Maps/demos/PopoverMarker.js b/front/odiparpack/app/containers/Maps/demos/PopoverMarker.js new file mode 100644 index 0000000..9a07f11 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/demos/PopoverMarker.js @@ -0,0 +1,55 @@ +import React from 'react'; +import { compose, withStateHandlers } from 'recompose'; +import LocalDining from '@material-ui/icons/LocalDining'; +import { + withScriptjs, + withGoogleMap, + GoogleMap, + Marker, + InfoWindow +} from 'react-google-maps'; + +const MapWithAMakredInfoWindow = compose( + withStateHandlers(() => ({ + isOpen: false, + }), { + onToggleOpen: ({ isOpen }) => () => ({ + isOpen: !isOpen, + }) + }), + withScriptjs, + withGoogleMap +)(props => ( + + + {props.isOpen && + + + A marked place + + + } + + +)); + +class PopoverMarker extends React.Component { + render() { + return ( + } + containerElement={
} + mapElement={
} + /> + ); + } +} + +export default PopoverMarker; diff --git a/front/odiparpack/app/containers/Maps/demos/SearchLocation.js b/front/odiparpack/app/containers/Maps/demos/SearchLocation.js new file mode 100644 index 0000000..16449d0 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/demos/SearchLocation.js @@ -0,0 +1,116 @@ +import React from 'react'; +import { compose, withProps, lifecycle } from 'recompose'; +import { + withScriptjs, + withGoogleMap, + GoogleMap, + Marker, +} from 'react-google-maps'; +import { SearchBox } from 'react-google-maps/lib/components/places/SearchBox'; +const _ = require('lodash'); + +const MapWithASearchBox = compose( + withProps({ + googleMapURL: 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places', + loadingElement:
, + containerElement:
, + mapElement:
, + }), + lifecycle({ + componentWillMount() { + const refs = {}; + + this.setState({ + bounds: null, + center: { + lat: 41.9, lng: -87.624 + }, + markers: [], + onMapMounted: ref => { + refs.map = ref; + }, + onBoundsChanged: () => { + this.setState({ + bounds: refs.map.getBounds(), + center: refs.map.getCenter(), + }); + }, + onSearchBoxMounted: ref => { + refs.searchBox = ref; + }, + onPlacesChanged: () => { + const places = refs.searchBox.getPlaces(); + const bounds = new google.maps.LatLngBounds(); // eslint-disable-line + + places.forEach(place => { + if (place.geometry.viewport) { + bounds.union(place.geometry.viewport); + } else { + bounds.extend(place.geometry.location); + } + }); + const nextMarkers = places.map(place => ({ + position: place.geometry.location, + })); + const nextCenter = _.get(nextMarkers, '0.position', this.state.center); + + this.setState({ + center: nextCenter, + markers: nextMarkers, + }); + // refs.map.fitBounds(bounds); + }, + }); + }, + }), + withScriptjs, + withGoogleMap +)(props => ( + + + + + {props.markers.map((marker, index) => + + )} + +)); + +class SearchLocation extends React.Component { + render() { + return ( + + ); + } +} + +export default SearchLocation; diff --git a/front/odiparpack/app/containers/Maps/demos/StreetView.js b/front/odiparpack/app/containers/Maps/demos/StreetView.js new file mode 100644 index 0000000..a8d3108 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/demos/StreetView.js @@ -0,0 +1,62 @@ +import React from 'react'; +import { compose, withProps } from 'recompose'; +import { + withScriptjs, + withGoogleMap, + GoogleMap, + StreetViewPanorama, + OverlayView, +} from 'react-google-maps'; + +const getPixelPositionOffset = (width, height) => ({ + x: -(width / 2), + y: -(height / 2), +}); + +const MapWithAMarker = compose( + withProps({ + googleMapURL: 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places', + loadingElement:
, + containerElement:
, + mapElement:
, + center: { lat: 49.2853171, lng: -123.1119202 }, + }), + withScriptjs, + withGoogleMap +)(props => ( + + + +
+ OverlayView +
+
+
+
+)); + +class StreetView extends React.Component { + render() { + return ( + } + containerElement={
} + mapElement={
} + /> + ); + } +} + +export default StreetView; diff --git a/front/odiparpack/app/containers/Maps/demos/Traffic.js b/front/odiparpack/app/containers/Maps/demos/Traffic.js new file mode 100644 index 0000000..0f5cdfd --- /dev/null +++ b/front/odiparpack/app/containers/Maps/demos/Traffic.js @@ -0,0 +1,37 @@ +import React from 'react'; +import { compose, withProps } from 'recompose'; +import { + withScriptjs, + withGoogleMap, + GoogleMap, + TrafficLayer, +} from 'react-google-maps'; + +const MapWithATrafficLayer = compose( + withProps({ + googleMapURL: 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places', + loadingElement:
, + containerElement:
, + mapElement:
, + }), + withScriptjs, + withGoogleMap +)(props => ( + + + +)); + +class Traffic extends React.Component { + render() { + return ( + + ); + } +} + +export default Traffic; diff --git a/front/odiparpack/app/containers/Maps/demos/index.js b/front/odiparpack/app/containers/Maps/demos/index.js new file mode 100644 index 0000000..33e8376 --- /dev/null +++ b/front/odiparpack/app/containers/Maps/demos/index.js @@ -0,0 +1,6 @@ +export BasicMarker from './BasicMarker'; +export PopoverMarker from './PopoverMarker'; +export Direction from './Direction'; +export SearchLocation from './SearchLocation'; +export Traffic from './Traffic'; +export StreetView from './StreetView'; -- cgit v1.2.3