githubEdit

Marker

Marker Component

Props

Prop
Type
Description

lngLat*

Marker Location

showPopup

boolean

Is Popup showing

onOpen

function

Called when Popup opens

onClose

function

Called when Popup closes

onDragStart

function

Called when Marker drag starts

onDragEnd

function

Called when Marker finshed dragging

onDrag

function

LngLatLikearrow-up-right position when Marker is dragged

*required

Example

import { Component, createSignal } from "solid-js";
import MapGL, { Viewport, Marker } from "solid-map-gl";
import 'mapbox-gl/dist/mapbox-gl.css';

const App: Component = () => {
  const [viewport, setViewport] = createSignal({
    center: [0, 52],
    zoom: 6,
  } as Viewport);

  return (
    <MapGL
      options={{ style: 'mb:dark' }}
      viewport={viewport()}
      onViewportChange={(evt: Viewport) => setViewport(evt)}
    >
      <Marker lngLat={[0, 52]} options={{ color: '#F00' }}>
        Hi there! 👋
      </Marker>
    </MapGL>
  );
};

Last updated