Commit 6081cba1 authored by Michael Underwood's avatar Michael Underwood
Browse files

Pass only explicitly set Leaflet options to Leaflet methods

parent d5fc7d32
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import {
  remapEvents,
  WINDOW_OR_GLOBAL,
  GLOBAL_LEAFLET_OPT,
  propsToLeafletOptions,
} from "../utils";
import { iconProps } from "../functions/icon";
import { componentProps, setupComponent } from "../functions/component";
@@ -47,22 +48,10 @@ export default {
      }

      const { options: componentOptions } = setupComponent(props);
      const options = {
        ...componentOptions,
        iconUrl: props.iconUrl,
        iconRetinaUrl: props.iconRetinaUrl,
        iconSize: props.iconSize,
        iconAnchor: props.iconAnchor,
        popupAnchor: props.popupAnchor,
        tooltipAnchor: props.tooltipAnchor,
        shadowUrl: props.shadowUrl,
        shadowRetinaUrl: props.shadowRetinaUrl,
        shadowSize: props.shadowSize,
        shadowAnchor: props.shadowAnchor,
        bgPos: props.bgPos,
        className: props.className,
        html: elHtml || props.html,
      };
      const options = propsToLeafletOptions(props, iconProps, componentOptions);
      if (elHtml) {
        options.html = elHtml;
      }

      iconObject = options.html ? divIcon(options) : icon(options);
      onDomEvent(iconObject, listeners);
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ export default {
      const { tileLayer, DomEvent } = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

      leafletRef.value = tileLayer(props.url, options);

      const listeners = remapEvents(context.attrs);
+6 −4
Original line number Diff line number Diff line
import { propsToLeafletOptions } from "../utils";
import { circleMarkerProps, setupCircleMarker } from "./circleMarker";

export const circleProps = {
@@ -16,10 +17,11 @@ export const setupCircle = (props, leafletRef, context) => {
    methods: circleMarkerMethods,
  } = setupCircleMarker(props, leafletRef, context);

  const options = {
    ...circleMarkerOptions,
    ...props,
  };
  const options = propsToLeafletOptions(
    props,
    circleProps,
    circleMarkerOptions
  );

  const methods = {
    ...circleMarkerMethods,
+4 −4
Original line number Diff line number Diff line
import { propsToLeafletOptions } from "../utils";
import { pathProps as pathProps, setupPath as pathSetup } from "./path";

export const circleMarkerProps = {
@@ -21,10 +22,9 @@ export const setupCircleMarker = (props, leafletRef, context) => {
    leafletRef,
    context
  );
  const options = {
    ...pathOptions,
    ...props,
  };

  const options = propsToLeafletOptions(props, circleMarkerProps, pathOptions);

  const methods = {
    ...pathMethods,
    setRadius(radius) {
+4 −4
Original line number Diff line number Diff line
import { onUnmounted, h } from "vue";
import { propsToLeafletOptions } from "../utils";
import { componentProps, setupComponent } from "./component";

export const controlProps = {
@@ -13,10 +14,8 @@ export const setupControl = (props, leafletRef) => {
    options: componentOptions,
    methods: componentMethods,
  } = setupComponent(props);
  const options = {
    ...componentOptions,
    position: props.position,
  };

  const options = propsToLeafletOptions(props, controlProps, componentOptions);

  const methods = {
    ...componentMethods,
@@ -40,5 +39,6 @@ export const render = (slots) => {
  if (slots.default) {
    return h("div", { ref: "root" }, slots.default());
  }

  return null;
};
Loading