Commit d675fabd authored by Michael Underwood's avatar Michael Underwood
Browse files

Standardize leafletObject naming and return from setup

parent b72dc18d
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -16,35 +16,36 @@ export default {
  name: "LCircle",
  props: circleProps,
  setup(props, context) {
    const leafletRef = ref({});
    const leafletObject = ref({});
    const ready = ref(false);

    const useGlobalLeaflet = inject(GLOBAL_LEAFLET_OPT);
    const addLayer = inject("addLayer");

    const { options, methods } = setupCircle(props, leafletRef, context);
    const { options, methods } = setupCircle(props, leafletObject, context);

    onMounted(async () => {
      const { circle, DomEvent } = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

      leafletRef.value = markRaw(circle(props.latLng, options));
      leafletObject.value = markRaw(circle(props.latLng, options));

      const listeners = remapEvents(context.attrs);
      DomEvent.on(leafletRef.value, listeners);
      DomEvent.on(leafletObject.value, listeners);

      propsBinder(methods, leafletRef.value, props);
      propsBinder(methods, leafletObject.value, props);

      addLayer({
        ...props,
        ...methods,
        leafletObject: leafletRef.value,
        leafletObject: leafletObject.value,
      });
      ready.value = true;
      nextTick(() => context.emit("ready", leafletRef.value));
      nextTick(() => context.emit("ready", leafletObject.value));
    });
    return { ready, leafletObject: leafletRef };

    return { ready, leafletObject };
  },
  render() {
    return render(this.ready, this.$slots);
+13 −8
Original line number Diff line number Diff line
@@ -19,35 +19,40 @@ export default {
  name: "LCircleMarker",
  props: circleMarkerProps,
  setup(props, context) {
    const leafletRef = ref({});
    const leafletObject = ref({});
    const ready = ref(false);

    const useGlobalLeaflet = inject(GLOBAL_LEAFLET_OPT);
    const addLayer = inject("addLayer");

    const { options, methods } = setupCircleMarker(props, leafletRef, context);
    const { options, methods } = setupCircleMarker(
      props,
      leafletObject,
      context
    );

    onMounted(async () => {
      const { circleMarker, DomEvent } = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

      leafletRef.value = markRaw(circleMarker(props.latLng, options));
      leafletObject.value = markRaw(circleMarker(props.latLng, options));

      const listeners = remapEvents(context.attrs);
      DomEvent.on(leafletRef.value, listeners);
      DomEvent.on(leafletObject.value, listeners);

      propsBinder(methods, leafletRef.value, props);
      propsBinder(methods, leafletObject.value, props);

      addLayer({
        ...props,
        ...methods,
        leafletObject: leafletRef.value,
        leafletObject: leafletObject.value,
      });
      ready.value = true;
      nextTick(() => context.emit("ready", leafletRef.value));
      nextTick(() => context.emit("ready", leafletObject.value));
    });
    return { ready, leafletObject: leafletRef };

    return { ready, leafletObject };
  },
  render() {
    return render(this.ready, this.$slots);
+8 −7
Original line number Diff line number Diff line
@@ -19,13 +19,13 @@ export default {
    },
  },
  setup(props, context) {
    const leafletRef = ref({});
    const leafletObject = ref({});
    const root = ref(null);

    const useGlobalLeaflet = inject(GLOBAL_LEAFLET_OPT);
    const registerControl = inject("registerControl");

    const { options, methods } = setupControl(props, leafletRef);
    const { options, methods } = setupControl(props, leafletObject);

    onMounted(async () => {
      const { Control, DomEvent } = useGlobalLeaflet
@@ -38,9 +38,9 @@ export default {
        },
      });

      leafletRef.value = markRaw(new LControl(options));
      propsBinder(methods, leafletRef.value, props);
      registerControl({ leafletObject: leafletRef.value });
      leafletObject.value = markRaw(new LControl(options));
      propsBinder(methods, leafletObject.value, props);
      registerControl({ leafletObject: leafletObject.value });

      if (props.disableClickPropagation) {
        DomEvent.disableClickPropagation(root.value);
@@ -48,9 +48,10 @@ export default {
      if (props.disableScrollPropagation) {
        DomEvent.disableScrollPropagation(root.value);
      }
      nextTick(() => context.emit("ready", leafletRef.value));
      nextTick(() => context.emit("ready", leafletObject.value));
    });
    return { root, leafletObject: leafletRef };

    return { root, leafletObject };
  },
  render() {
    return render(this.$slots);
+8 −7
Original line number Diff line number Diff line
@@ -10,24 +10,25 @@ export default {
  name: "LControlAttribution",
  props: controlAttributionProps,
  setup(props, context) {
    const leafletRef = ref({});
    const leafletObject = ref({});

    const useGlobalLeaflet = inject(GLOBAL_LEAFLET_OPT);
    const registerControl = inject("registerControl");

    const { options, methods } = setupControlAttribution(props, leafletRef);
    const { options, methods } = setupControlAttribution(props, leafletObject);

    onMounted(async () => {
      const { control } = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

      leafletRef.value = markRaw(control.attribution(options));
      propsBinder(methods, leafletRef.value, props);
      registerControl({ leafletObject: leafletRef.value });
      nextTick(() => context.emit("ready", leafletRef.value));
      leafletObject.value = markRaw(control.attribution(options));
      propsBinder(methods, leafletObject.value, props);
      registerControl({ leafletObject: leafletObject.value });
      nextTick(() => context.emit("ready", leafletObject.value));
    });
    return { leafletObject: leafletRef.value };

    return { leafletObject };
  },
  render() {
    return null;
+8 −7
Original line number Diff line number Diff line
@@ -10,30 +10,31 @@ export default {
  name: "LControlLayers",
  props: controlLayersProps,
  setup(props, context) {
    const leafletRef = ref({});
    const leafletObject = ref({});

    const useGlobalLeaflet = inject(GLOBAL_LEAFLET_OPT);
    const registerLayerControl = inject("registerLayerControl");

    const { options, methods } = setupControlLayers(props, leafletRef);
    const { options, methods } = setupControlLayers(props, leafletObject);

    onMounted(async () => {
      const { control } = useGlobalLeaflet
        ? WINDOW_OR_GLOBAL.L
        : await import("leaflet/dist/leaflet-src.esm");

      leafletRef.value = markRaw(control.layers(null, null, options));
      leafletObject.value = markRaw(control.layers(null, null, options));

      propsBinder(methods, leafletRef.value, props);
      propsBinder(methods, leafletObject.value, props);

      registerLayerControl({
        ...props,
        ...methods,
        leafletObject: leafletRef.value,
        leafletObject: leafletObject.value,
      });
      nextTick(() => context.emit("ready", leafletRef.value));
      nextTick(() => context.emit("ready", leafletObject.value));
    });
    return { leafletObject: leafletRef.value };

    return { leafletObject };
  },
  render() {
    return null;
Loading