Skip to content

Commit

Permalink
fix: popup set DOM Content instead of html str ✨
Browse files Browse the repository at this point in the history
Signed-off-by: Vinayak Kulkarni <[email protected]>
  • Loading branch information
vinayakkulkarni committed Mar 14, 2023
1 parent 6228dde commit 26f80c4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/popups/VPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
</template>
<script lang="ts">
import type { LngLatLike, Map, Marker, PopupOptions } from 'maplibre-gl';
import { Popup } from 'maplibre-gl';
import type { PropType, Ref } from 'vue';
import { Popup } from 'maplibre-gl';
import { defineComponent, onBeforeUnmount, onMounted, ref } from 'vue';
import { popupEvents } from '../constants/events';
import { MapKey } from '../utils/symbols';
import { injectStrict } from '../utils';
import { injectStrict, MapKey } from '../utils';
export default defineComponent({
name: 'VPopup',
Expand Down Expand Up @@ -53,6 +52,7 @@
onMounted(() => {
if (loaded.value) {
setPopupContent();
setPopupCoordinates();
addToMarker();
listenPopupEvents();
Expand All @@ -67,15 +67,20 @@
removePopupEvents();
});
/**
* Sets the HTML content for the popup
*
* @returns {void}
*/
function setPopupContent(): void {
popup.setDOMContent(content.value as Node);
}
/**
* Set popup coordinates
*
* @returns {void}
*/
function setPopupCoordinates(): void {
const { outerHTML }: { outerHTML: string } =
content.value!.children[0].children[0];
popup.setHTML(outerHTML);
popup.setLngLat(props.coordinates);
}
Expand Down

0 comments on commit 26f80c4

Please sign in to comment.