forked from origo-map/origo
-
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.
feature: center marker for externalurl (origo-map#1686)
Fixes origo-map#1672 Adds a centerMarker component to the viewer, easy to use with show/hide methods. Future improvements are to use this along with eg the position control, but they somehow has to respect each other.
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component, Icon, dom } from '../ui'; | ||
|
||
export default function CenterMarker() { | ||
let viewer; | ||
let markerEl; | ||
|
||
function createMarker() { | ||
const markerIcon = Icon({ | ||
icon: '#o_centerposition_24px', | ||
cls: 'o-position-marker hidden' | ||
}); | ||
const markerElement = dom.html(markerIcon.render()); | ||
document.getElementById(`${viewer.getId()}`).appendChild(markerElement); | ||
markerEl = document.getElementById(markerIcon.getId()); | ||
} | ||
|
||
return Component({ | ||
name: 'centermarker', | ||
onAdd(evt) { | ||
viewer = evt.target; | ||
createMarker(); | ||
}, | ||
hide: function hide() { | ||
markerEl.classList.add('hidden'); | ||
}, | ||
show: function hide() { | ||
markerEl.classList.remove('hidden'); | ||
} | ||
}); | ||
} |
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
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