diff --git a/src/examples/AzureLayer.tsx b/src/examples/AzureLayer.tsx new file mode 100644 index 0000000..0b41527 --- /dev/null +++ b/src/examples/AzureLayer.tsx @@ -0,0 +1,98 @@ +import React, { useMemo } from "react"; +import { + AzureMapsProvider, + AzureMap, + AzureMapDataSourceProvider, + AzureMapLayerProvider, + AzureMapFeature, + AzureMapHtmlMarker, + IAzureMapOptions, + IAzureMapHtmlMarkerEvent +} from "react-azure-maps"; +import atlas, { AuthenticationType, data } from "azure-maps-control"; + +const AzureLayer: React.FC = () => { + const point1 = new data.Position(-100.01, 45.01); + const point2 = new data.Position(-100.2, 45.1); + + + const option: IAzureMapOptions = useMemo(() => { + return { + authOptions: { + authType: AuthenticationType.subscriptionKey, + subscriptionKey: "tTk1JVEaeNvDkxxnxHm9cYaCvqlOq1u-fXTvyXn2XkA" + }, + center: [-100.01, 45.01], + zoom: 2, + view: "Auto" + }; + }, []); + + const onClick = () => { + console.log("ASD"); + }; + + const azureHtmlMapMarkerOptions = { + htmlContent: '
', + position: [-110, 45] + }; + + const eventToMarker: Array = [ + { eventName: "click", callback: onClick } + ]; + + return ( + <> +
+ + + + + + + + + +
+
+ + + + + + + + + +
+ + ); +}; + +export default AzureLayer; diff --git a/src/examples/DefaultMap.tsx b/src/examples/DefaultMap.tsx index ed013b6..3d1e858 100644 --- a/src/examples/DefaultMap.tsx +++ b/src/examples/DefaultMap.tsx @@ -18,7 +18,7 @@ const DefaultMap: React.FC = () => { return { authOptions: { authType: AuthenticationType.subscriptionKey, - subscriptionKey: "" + subscriptionKey: "tTk1JVEaeNvDkxxnxHm9cYaCvqlOq1u-fXTvyXn2XkA" }, center: [-100.01, 45.01], zoom: 12, @@ -43,8 +43,8 @@ const DefaultMap: React.FC = () => {
- - + + { > diff --git a/src/examples/MyDump/MyDump.tsx b/src/examples/MyDump/MyDump.tsx new file mode 100644 index 0000000..5ce362b --- /dev/null +++ b/src/examples/MyDump/MyDump.tsx @@ -0,0 +1,120 @@ +import React, {memo, useMemo, useState} from "react"; +import { + AzureMap, + AzureMapDataSourceProvider, + AzureMapFeature, + AzureMapHtmlMarker, + AzureMapLayerProvider, + AzureMapsProvider, + IAzureMapHtmlMarkerEvent, + IAzureMapOptions +} from "react-azure-maps"; +import {AuthenticationType, data} from "azure-maps-control"; + +const point1 = new data.Position(-100.01, 45.01); +const point2 = new data.Position(-120.2, 45.1); +const point3 = new data.Position(-120.2, 50.1); + + + +const MyDump: React.FC = () => { + const [dump, setDump] = useState('START'); + const [markers, setMarkers] = useState([point1, point2, point3]); + + const option: IAzureMapOptions = useMemo(() => { + return { + authOptions: { + authType: AuthenticationType.subscriptionKey, + subscriptionKey: "tTk1JVEaeNvDkxxnxHm9cYaCvqlOq1u-fXTvyXn2XkA" + }, + center: [-100.01, 45.01], + zoom: 2, + view: "Auto" + }; + }, []); + + const onClick = () => { + console.log("ASD"); + }; + + const azureHtmlMapMarkerOptions = { + htmlContent: '
', + position: [-110, 45] + }; + + const eventToMarker: Array = [ + {eventName: "click", callback: onClick} + ]; + + const addMarker = () => { + const randomLongitude = Math.floor(Math.random() * (-80 - (-120)) + -120); + const randomLatitude = Math.floor(Math.random() * (30 - 65) + 65); + const newPoint = new data.Position(randomLongitude, randomLatitude) + setMarkers([newPoint]) + } + + const renderPoint = (marker: data.Position) => { + + + const rendId = Math.floor(Math.random() * (80 - (120)) + 120); + + return + } + + + console.log("MAP") + return ( + <> + MAP {dump} +
+
ADD
+
setMarkers([[-22, 55]])}> REMOVE LAST
+
TRHRS
+
+
+ + + + + {markers.map(marker => + renderPoint(marker) + )} + {/*{renderPoint([12, 23])}*/} + + + + +
+ + ); +}; + +const styles = { + buttonContainer: { + height: 40, + display: 'flex', + justifyContent: 'space-around', + padding: 10 + }, + button: { + height: 35, + width: 80, + backgroundColor: '#68aba3', + "text-align": "center", + } +} + +export default memo(MyDump); diff --git a/src/examples/MyDump/MyDumpContainer.tsx b/src/examples/MyDump/MyDumpContainer.tsx new file mode 100644 index 0000000..a6bfa9a --- /dev/null +++ b/src/examples/MyDump/MyDumpContainer.tsx @@ -0,0 +1,29 @@ +// @flow +import * as React from 'react'; +import MyDump from "./MyDump"; +import {MyDumpWrapper} from "./MyDumpWrapper"; + +type Props = { + +}; +export const MyDumpContainer = (props: Props) => { + return ( +
+
+ My Dump container + + +
+
+ ); +}; + + +export const styles = { + buttons: { + border: "solid", + borderSize: "2px", + flex: 1, + borderColor: '#885875' + } +} diff --git a/src/examples/MyDump/MyDumpWrapper.tsx b/src/examples/MyDump/MyDumpWrapper.tsx new file mode 100644 index 0000000..8838a02 --- /dev/null +++ b/src/examples/MyDump/MyDumpWrapper.tsx @@ -0,0 +1,41 @@ +import * as React from 'react'; +import {useState} from "react"; +import MyDump from "./MyDump"; + +export type DumpProps = { + text?: String +}; +export const MyDumpWrapper = (props: DumpProps) => { + const [dump, setDump] = useState('START'); + console.log('Wrapper') + return ( +
+ Wrapper {dump} +
+
setDump('FIRST BUTTON')} /> +
setDump('SECOND BUTTON')}/> +
+
+ +
+ ); +}; + +export const wrapperStyles = { + wrapper: { + border: "solid", + borderSize: "2px", + borderColor: '#2113ab' + }, + buttonContainer: { + height: 40, + display: 'flex', + justifyContent: 'space-around', + padding: 10 + }, + button: { + height: 35, + width: 80, + backgroundColor: '#2213ab' + } +} diff --git a/src/examples/examplesList.tsx b/src/examples/examplesList.tsx index 6b2e331..f57caa1 100644 --- a/src/examples/examplesList.tsx +++ b/src/examples/examplesList.tsx @@ -1,4 +1,7 @@ import DefaultMap from "./DefaultMap"; +import AzureLayer from "./AzureLayer"; +import MyDump from "./MyDump/MyDump"; +import {MyDumpContainer} from "./MyDump/MyDumpContainer"; export type MapExampleItem = { name: string; @@ -15,8 +18,13 @@ export const examplesList: MapExampleItem[] = [ exact: true }, { - name: "Default map 2", - component: DefaultMap, - path: "/foo" + name: "Layers", + component: AzureLayer, + path: "/layers" + }, + { + name: "MyDump", + component: MyDumpContainer, + path: "/myDump" } ];