-
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
2af87cf
commit 8902cab
Showing
6 changed files
with
60 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<!DOCTYPE html> | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Vanilla example @mappable-world/mappable-default-ui-theme</title> | ||
|
@@ -15,18 +15,16 @@ | |
const {MMap, MMapDefaultSchemeLayer, MMapDefaultFeaturesLayer, MMapControls} = mappable; | ||
|
||
const {MMapZoomControl} = await mappable.import('@mappable-world/[email protected]'); | ||
const {MMapButtonExample} = await mappable.import('@mappable-world/mappable-default-ui-theme'); | ||
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((defaultFeatures = new MMapDefaultFeaturesLayer())); | ||
map.addChild(new MMapControls({position: 'right'}).addChild(new MMapZoomControl({}))); | ||
|
||
map.addChild( | ||
new MMapControls({position: 'right'}) | ||
.addChild(new MMapZoomControl({})) | ||
.addChild(new MMapButtonExample({text: 'My button', onClick: () => alert('Click!')})) | ||
); | ||
const coordinates = [55.289051, 25.229907]; | ||
map.addChild(new MMapDefaultMarker({coordinates, color: '#F09A75', name: 'auto'})); | ||
} | ||
</script> | ||
|
||
|
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,13 @@ | ||
.mappable--point { | ||
box-sizing: border-box; | ||
height: 8px; | ||
width: 8px; | ||
border: 2px solid #f8f8f8; | ||
position: absolute; | ||
transform: translate(-50%, -50%); | ||
border-radius: 50%; | ||
} | ||
|
||
.mappable--point svg { | ||
transform: translate(calc(-50% + 2px), calc(-100% + 2px)); | ||
} |
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 {MMapMarker, MMapMarkerProps} from '@mappable-world/mappable-types'; | ||
import {IconName} from '../icons/types/icons'; | ||
import pin from './pin.svg'; | ||
import './index.css'; | ||
|
||
export type MMapDefaultMarkerProps = MMapMarkerProps & { | ||
name: IconName; | ||
color: string; | ||
}; | ||
|
||
export class MMapDefaultMarker extends mappable.MMapComplexEntity<MMapDefaultMarkerProps> { | ||
private _marker: MMapMarker; | ||
private _markerElement: HTMLElement; | ||
|
||
constructor(props: MMapDefaultMarkerProps) { | ||
super(props); | ||
} | ||
|
||
protected _onAttach(): void { | ||
this._markerElement = document.createElement('mappable'); | ||
this._markerElement.classList.add('mappable--point'); | ||
this._markerElement.innerHTML = pin; | ||
this._markerElement.style.color = this._props.color; | ||
this._markerElement.style.backgroundColor = this._props.color; | ||
|
||
this._marker = new mappable.MMapMarker(this._props, this._markerElement); | ||
this.addChild(this._marker); | ||
} | ||
|
||
protected _onUpdate(propsDiff: Partial<MMapDefaultMarkerProps>): void { | ||
if (propsDiff.color !== undefined) { | ||
this._markerElement.style.color = this._props.color; | ||
} | ||
this._marker.update(this._props); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 +1,2 @@ | ||
export * from './MMapButtonExample/MMapButtonExample'; | ||
export * from './MMapDefaultMarker'; |
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,4 @@ | ||
declare module '*.svg' { | ||
const content: string; | ||
export default content; | ||
} |