-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0677f5a
commit 8aeb780
Showing
10 changed files
with
318 additions
and
6 deletions.
There are no files selected for viewing
Empty file.
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,5 @@ | ||
import type {LngLat, MMapLocationRequest} from '@mappable-world/mappable-types'; | ||
|
||
export const CENTER: LngLat = [55.442795, 25.24107]; | ||
|
||
export const LOCATION: MMapLocationRequest = {center: CENTER, zoom: 9}; |
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,37 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>React example mappable-default-ui-theme</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> | ||
<script crossorigin src="https://unpkg.com/react@17/umd/react.production.min.js"></script> | ||
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script> | ||
<script crossorigin src="https://unpkg.com/@babel/standalone@7/babel.min.js"></script> | ||
<script src="https://js.api.mappable.world/3.0/?apikey=%APIKEY%&lang=en_US"></script> | ||
|
||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="react, typescript" | ||
type="text/babel" | ||
src="../../index.ts" | ||
></script> | ||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="react, typescript" | ||
type="text/babel" | ||
src="../common.ts" | ||
></script> | ||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="react, typescript" | ||
type="text/babel" | ||
src="./index.tsx" | ||
></script> | ||
|
||
<link rel="stylesheet" href="../../index.css" /> | ||
<link rel="stylesheet" href="../common.css" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
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,49 @@ | ||
import {MarkerPopupProps, MarkerSizeProps} from '../../src'; | ||
import {CENTER, LOCATION} from '../common'; | ||
|
||
window.map = null; | ||
|
||
main(); | ||
async function main() { | ||
const [mappableReact] = await Promise.all([mappable.import('@mappable-world/mappable-reactify'), mappable.ready]); | ||
const reactify = mappableReact.reactify.bindTo(React, ReactDOM); | ||
|
||
const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} = | ||
reactify.module(mappable); | ||
|
||
const {useState, useCallback} = React; | ||
|
||
const {MMapDefaultMarker} = reactify.module(await mappable.import('@mappable-world/mappable-default-ui-theme')); | ||
|
||
ReactDOM.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
document.getElementById('app') | ||
); | ||
|
||
function App() { | ||
const [location] = useState(LOCATION); | ||
const [size, setSize] = useState<MarkerSizeProps>('normal'); | ||
const [popup] = useState<MarkerPopupProps>({ | ||
title: 'Popup', | ||
description: 'Description for this marker', | ||
action: 'Action' | ||
}); | ||
|
||
return ( | ||
<MMap location={location} ref={(x) => (map = x)}> | ||
<MMapDefaultSchemeLayer /> | ||
<MMapDefaultFeaturesLayer /> | ||
|
||
<MMapDefaultMarker coordinates={CENTER} iconName="fallback" size={size} popup={popup} /> | ||
|
||
<MMapControls position="top left"> | ||
<MMapControlButton text="Normal" onClick={useCallback(() => setSize('normal'), [])} /> | ||
<MMapControlButton text="Small" onClick={useCallback(() => setSize('small'), [])} /> | ||
<MMapControlButton text="Micro" onClick={useCallback(() => setSize('micro'), [])} /> | ||
</MMapControls> | ||
</MMap> | ||
); | ||
} | ||
} |
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,35 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Vanilla example mappable-default-ui-theme</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> | ||
<script crossorigin src="https://unpkg.com/@babel/standalone@7/babel.min.js"></script> | ||
<script src="https://js.api.mappable.world/3.0/?apikey=%APIKEY%&lang=en_US"></script> | ||
|
||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="react, typescript" | ||
type="text/babel" | ||
src="../../index.ts" | ||
></script> | ||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="typescript" | ||
type="text/babel" | ||
src="../common.ts" | ||
></script> | ||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="typescript" | ||
type="text/babel" | ||
src="./index.ts" | ||
></script> | ||
|
||
<link rel="stylesheet" href="../../index.css" /> | ||
<link rel="stylesheet" href="../common.css" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
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,36 @@ | ||
import {CENTER, LOCATION} from '../common'; | ||
window.map = null; | ||
|
||
main(); | ||
async function main() { | ||
await mappable.ready; | ||
const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} = mappable; | ||
|
||
const {MMapDefaultMarker} = await mappable.import('@mappable-world/mappable-default-ui-theme'); | ||
|
||
map = new MMap(document.getElementById('app'), {location: LOCATION}); | ||
|
||
map.addChild(new MMapDefaultSchemeLayer({})); | ||
map.addChild(new MMapDefaultFeaturesLayer({})); | ||
|
||
const marker = new MMapDefaultMarker({ | ||
coordinates: CENTER, | ||
iconName: 'fallback', | ||
size: 'normal', | ||
popup: { | ||
title: 'Popup', | ||
description: 'Description for this marker', | ||
action: 'Action' | ||
} | ||
}); | ||
|
||
map.addChild(marker); | ||
|
||
map.addChild( | ||
new MMapControls({position: 'top left'}, [ | ||
new MMapControlButton({text: 'Normal', onClick: () => marker.update({size: 'normal'})}), | ||
new MMapControlButton({text: 'Small', onClick: () => marker.update({size: 'small'})}), | ||
new MMapControlButton({text: 'Micro', onClick: () => marker.update({size: 'micro'})}) | ||
]) | ||
); | ||
} |
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,36 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Vue example mappable-default-ui-theme</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" /> | ||
<script crossorigin src="https://unpkg.com/vue@3/dist/vue.global.js"></script> | ||
<script crossorigin src="https://unpkg.com/@babel/standalone@7/babel.min.js"></script> | ||
<script src="https://js.api.mappable.world/3.0/?apikey=%APIKEY%&lang=en_US"></script> | ||
|
||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="react, typescript" | ||
type="text/babel" | ||
src="../../index.ts" | ||
></script> | ||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="typescript" | ||
type="text/babel" | ||
src="../common.ts" | ||
></script> | ||
<script | ||
data-plugins="transform-modules-umd" | ||
data-presets="typescript" | ||
type="text/babel" | ||
src="./index.ts" | ||
></script> | ||
|
||
<link rel="stylesheet" href="../../index.css" /> | ||
<link rel="stylesheet" href="../common.css" /> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
</body> | ||
</html> |
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,54 @@ | ||
import {MarkerPopupProps, MarkerSizeProps} from '../../src'; | ||
import {CENTER, LOCATION} from '../common'; | ||
|
||
window.map = null; | ||
|
||
main(); | ||
async function main() { | ||
const [mappableVue] = await Promise.all([mappable.import('@mappable-world/mappable-vuefy'), mappable.ready]); | ||
const vuefy = mappableVue.vuefy.bindTo(Vue); | ||
|
||
const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls, MMapControlButton} = | ||
vuefy.module(mappable); | ||
|
||
const {MMapDefaultMarker} = vuefy.module(await mappable.import('@mappable-world/mappable-default-ui-theme')); | ||
|
||
const app = Vue.createApp({ | ||
components: { | ||
MMap, | ||
MMapDefaultSchemeLayer, | ||
MMapDefaultFeaturesLayer, | ||
MMapControls, | ||
MMapControlButton, | ||
MMapDefaultMarker | ||
}, | ||
setup() { | ||
const size = Vue.ref<MarkerSizeProps>('normal'); | ||
const popup = Vue.ref<MarkerPopupProps>({ | ||
title: 'Popup', | ||
description: 'Description for this marker', | ||
action: 'Action' | ||
}); | ||
const refMap = (ref: any) => { | ||
window.map = ref?.entity; | ||
}; | ||
const setNormalSize = () => (size.value = 'normal'); | ||
const setSmallSize = () => (size.value = 'small'); | ||
const setMicroSize = () => (size.value = 'micro'); | ||
|
||
return {LOCATION, CENTER, size, popup, refMap, setNormalSize, setSmallSize, setMicroSize}; | ||
}, | ||
template: ` | ||
<MMap :location="LOCATION" :ref="refMap"> | ||
<MMapDefaultSchemeLayer /> | ||
<MMapDefaultFeaturesLayer /> | ||
<MMapDefaultMarker :coordinates="CENTER" iconName="fallback" :size="size" :popup="popup" /> | ||
<MMapControls position="top left"> | ||
<MMapControlButton text="Normal" :onClick="setNormalSize" /> | ||
<MMapControlButton text="Small" :onClick="setSmallSize" /> | ||
<MMapControlButton text="Micro" :onClick="setMicroSize" /> | ||
</MMapControls> | ||
</MMap>` | ||
}); | ||
app.mount('#app'); | ||
} |
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.