Commit 39a6cc7e authored by Michael Underwood's avatar Michael Underwood
Browse files

Rename `mapRef` to `leafletRef` everywhere

parent 60e19542
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -7,22 +7,22 @@ export default {
  name: "LControlLayers",
  props,
  setup(props) {
    const mapRef = ref({});
    const leafletRef = ref({});

    const registerLayerControl = inject("registerLayerControl");
    const { options, methods } = controlSetup(props, mapRef);
    const { options, methods } = controlSetup(props, leafletRef);
    onMounted(async () => {
      const { control, setOptions } = await import(
        "leaflet/dist/leaflet-src.esm"
      );

      mapRef.value = control.layers(null, null, options);
      propsBinder(methods, mapRef.value, props, setOptions);
      leafletRef.value = control.layers(null, null, options);
      propsBinder(methods, leafletRef.value, props, setOptions);

      registerLayerControl({
        ...props,
        ...methods,
        mapObject: mapRef.value,
        mapObject: leafletRef.value,
      });
    });
  },
+7 −7
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ export default {
  name: "LMarker",
  props,
  setup(props, context) {
    const mapRef = ref({});
    const leafletRef = ref({});
    const ready = ref(false);

    const schematics = reactive({
@@ -20,7 +20,7 @@ export default {
    const addMapLayer = inject("addMapLayer");
    const { options, methods } = markerSetup(
      props,
      mapRef,
      leafletRef,
      context,
      schematics
    );
@@ -31,14 +31,14 @@ export default {
      );
      schematics.latLng = latLng;

      mapRef.value = marker(props.latLng, options);
      leafletRef.value = marker(props.latLng, options);

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

      mapRef.value.on("move", debounce(methods.latLngSync, 100));
      propsBinder(methods, mapRef.value, props, setOptions);
      addMapLayer({ ...props, ...methods, mapObject: mapRef.value });
      leafletRef.value.on("move", debounce(methods.latLngSync, 100));
      propsBinder(methods, leafletRef.value, props, setOptions);
      addMapLayer({ ...props, ...methods, mapObject: leafletRef.value });
      ready.value = true;
    });
    return { ready };
+6 −6
Original line number Diff line number Diff line
@@ -6,22 +6,22 @@ import { props, setup as tileLayerSetup } from "../functions/tileLayer";
export default {
  props,
  setup(props, context) {
    const mapRef = ref({});
    const leafletRef = ref({});
    const addMapLayer = inject("addMapLayer");

    const { options, methods } = tileLayerSetup(props, mapRef);
    const { options, methods } = tileLayerSetup(props, leafletRef);

    onMounted(async () => {
      const { tileLayer, DomEvent, setOptions } = await import(
        "leaflet/dist/leaflet-src.esm"
      );
      mapRef.value = tileLayer(props.url, options);
      leafletRef.value = tileLayer(props.url, options);

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

      propsBinder(methods, mapRef.value, props, setOptions);
      addMapLayer({ ...props, ...methods, mapObject: mapRef.value });
      propsBinder(methods, leafletRef.value, props, setOptions);
      addMapLayer({ ...props, ...methods, mapObject: leafletRef.value });
    });
  },
  render() {
+12 −7
Original line number Diff line number Diff line
@@ -10,24 +10,29 @@ export default {
  name: "LTooltip",
  props,
  setup(props, context) {
    const mapRef = ref({});
    const leafletRef = ref({});
    const root = ref(null);

    const lMethods = inject("leafLetMethods");
    const { options, methods } = tooltipSetup(props, mapRef, context, lMethods);
    const { options, methods } = tooltipSetup(
      props,
      leafletRef,
      context,
      lMethods
    );

    onMounted(async () => {
      const { tooltip, DomEvent, setOptions } = await import(
        "leaflet/dist/leaflet-src.esm"
      );

      mapRef.value = tooltip(options);
      leafletRef.value = tooltip(options);

      propsBinder(methods, mapRef.value, props, setOptions);
      propsBinder(methods, leafletRef.value, props, setOptions);
      const listeners = remapEvents(context.attrs);
      DomEvent.on(mapRef.value, listeners);
      mapRef.value.setContent(props.content || root.value);
      lMethods.bindTooltip({ mapObject: mapRef.value });
      DomEvent.on(leafletRef.value, listeners);
      leafletRef.value.setContent(props.content || root.value);
      lMethods.bindTooltip({ mapObject: leafletRef.value });
    });
    return { root };
  },
+3 −3
Original line number Diff line number Diff line
@@ -6,10 +6,10 @@ export const props = {
    default: "topright",
  },
};
export const setup = (mapRef) => {
export const setup = (leafletRef) => {
  onUnmounted(() => {
    if (mapRef.value) {
      mapRef.value.remove();
    if (leafletRef.value) {
      leafletRef.value.remove();
    }
  });
};
Loading