@heycar/heycars-map 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -9,7 +9,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  const Vue = require("vue");
10
10
  const style = "";
11
11
  const name = "@heycar/heycars-map";
12
- const version = "0.8.4";
12
+ const version = "0.8.5";
13
13
  const type = "module";
14
14
  const scripts = {
15
15
  dev: "vite -c vite.config.dev.ts",
@@ -6122,11 +6122,6 @@ const usePointsLabelDirection = (props) => {
6122
6122
  });
6123
6123
  directionsRef.value = directions;
6124
6124
  labeledPlacesRef.value = noOverlapPlaces;
6125
- console.log(
6126
- "usePointsLabelDirection basePlace, noOverlapPlaces = ",
6127
- basePlace.displayName,
6128
- noOverlapPlaces.map((item) => item.displayName)
6129
- );
6130
6125
  }
6131
6126
  );
6132
6127
  return { directionsRef, labeledPlacesRef, isContainBasePlaceRef };
@@ -6135,27 +6130,40 @@ function createLabelDirections(props) {
6135
6130
  const { sortedPoints, widthLimit, heightLimit, distanceFn } = props;
6136
6131
  const len = sortedPoints.length;
6137
6132
  const result = [];
6133
+ const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2) => {
6134
+ if (isLimited2)
6135
+ return reverse(prevDirection2);
6136
+ if (isDoubleLimited2 && prevDx2 < 0 && prevDirection2 === "left")
6137
+ return "left";
6138
+ return "right";
6139
+ };
6138
6140
  let prevDirection = "right";
6139
6141
  let isLimited = false;
6142
+ let isDoubleLimited = false;
6143
+ let prevDx = Infinity;
6140
6144
  for (let idx = 0; idx < len; idx++) {
6141
6145
  if (idx === len - 1) {
6142
- const direction2 = isLimited ? reverse(prevDirection) : "right";
6146
+ const direction2 = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6143
6147
  result.push(direction2);
6144
6148
  continue;
6145
6149
  }
6146
6150
  if (idx === 0) {
6147
6151
  const [dx2, dy2] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6148
6152
  isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6153
+ isDoubleLimited = dx2 > -widthLimit * 2 && dx2 < widthLimit * 2 && dy2 > -heightLimit && dy2 < heightLimit;
6149
6154
  const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6150
6155
  result.push(direction2);
6151
6156
  prevDirection = direction2;
6157
+ prevDx = dx2;
6152
6158
  continue;
6153
6159
  }
6154
6160
  const [dx, dy] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6155
- const direction = isLimited ? reverse(prevDirection) : "right";
6161
+ const direction = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6156
6162
  result.push(direction);
6157
6163
  prevDirection = direction;
6164
+ prevDx = dx;
6158
6165
  isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6166
+ isDoubleLimited = dx > -widthLimit * 2 && dx < widthLimit * 2 && dy > -heightLimit && dy < heightLimit;
6159
6167
  }
6160
6168
  return result;
6161
6169
  }
@@ -6164,7 +6172,8 @@ function filterNoOverlapPlaces(props) {
6164
6172
  const measureOverlap = (place1, place2) => {
6165
6173
  const [dx, dy] = distanceFn(place2point(place1), place2point(place2));
6166
6174
  const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6167
- console.log(
6175
+ spaceLog(
6176
+ "usePointsLabelDirection",
6168
6177
  "p1, p2, dx, dy, isOverlap = ",
6169
6178
  place1.displayName,
6170
6179
  place2.displayName,
@@ -6248,25 +6257,23 @@ var labelLayout = "fhyw8b";
6248
6257
  var labelStroke = "fhyw8d fhyw8c";
6249
6258
  var placeCircleLayout = createRuntimeFn({ defaultClassName: "fhyw80", variantClassNames: { textAlign: { left: "fhyw81", right: "fhyw82" } }, defaultVariants: {}, compoundVariants: [] });
6250
6259
  var placeIcon = createRuntimeFn({ defaultClassName: "fhyw88", variantClassNames: { hideIcon: { true: "fhyw89", false: "fhyw8a" } }, defaultVariants: {}, compoundVariants: [] });
6260
+ const DEFAULT_TEXT_ALIGN = "right";
6251
6261
  const APlaceCircle = defineSetup(function APlaceCircle2(props, {
6252
6262
  emit
6253
6263
  }) {
6254
- const textAlignRef = Vue.computed(() => {
6255
- var _a;
6256
- return (_a = props.textAlign) != null ? _a : "right";
6257
- });
6258
6264
  const contentRef = Vue.computed(() => {
6259
6265
  const {
6260
- hideIcon = false
6266
+ hideIcon = false,
6267
+ textAlign = DEFAULT_TEXT_ALIGN
6261
6268
  } = props;
6262
6269
  return `
6263
6270
  <div class="APlaceCircle ${placeCircleLayout({
6264
- textAlign: textAlignRef.value
6271
+ textAlign
6265
6272
  })}">
6266
6273
  <img class="${placeIcon({
6267
6274
  hideIcon
6268
6275
  })} ${amapPlaceIconLayout({
6269
- textAlign: textAlignRef.value
6276
+ textAlign
6270
6277
  })}" src="${imgPlaceCircle}">
6271
6278
  <div class="${labelLayout}">
6272
6279
  <div class="${labelStroke}">${props.label}</div>
@@ -6277,23 +6284,27 @@ const APlaceCircle = defineSetup(function APlaceCircle2(props, {
6277
6284
  });
6278
6285
  const contentWithoutLabelRef = Vue.computed(() => {
6279
6286
  const {
6280
- hideIcon = false
6287
+ hideIcon = false,
6288
+ textAlign = DEFAULT_TEXT_ALIGN
6281
6289
  } = props;
6282
6290
  return `<img class="APlaceCircle ${placeIcon({
6283
6291
  hideIcon
6284
6292
  })} ${amapPlaceIconLayout({
6285
- textAlign: textAlignRef.value
6293
+ textAlign
6286
6294
  })}" src="${imgPlaceCircle}">`;
6287
6295
  });
6288
6296
  const handleClick = () => {
6289
6297
  emit("click", props.position);
6290
6298
  };
6291
6299
  return () => {
6300
+ const {
6301
+ textAlign = DEFAULT_TEXT_ALIGN
6302
+ } = props;
6292
6303
  return Vue.h(AmapMarker, {
6293
6304
  "attrs": {
6294
6305
  "position": props.position,
6295
6306
  "content": props.label ? contentRef.value : contentWithoutLabelRef.value,
6296
- "anchor": textAlignRef.value === "left" ? AnchorType.middleRight : AnchorType.middleLeft,
6307
+ "anchor": textAlign === "left" ? AnchorType.middleRight : AnchorType.middleLeft,
6297
6308
  "zIndex": ZINDEX_PLACE_LAYER
6298
6309
  },
6299
6310
  "on": {
@@ -6305,19 +6316,16 @@ const APlaceCircle = defineSetup(function APlaceCircle2(props, {
6305
6316
  const GPlaceCircle = defineSetup(function GPlaceCircle2(props, {
6306
6317
  emit
6307
6318
  }) {
6308
- const textAlignRef = Vue.computed(() => {
6309
- var _a;
6310
- return (_a = props.textAlign) != null ? _a : "right";
6311
- });
6312
6319
  const contentRef = Vue.computed(() => {
6313
6320
  const {
6314
- hideIcon = false
6321
+ hideIcon = false,
6322
+ textAlign = DEFAULT_TEXT_ALIGN
6315
6323
  } = props;
6316
6324
  return createDom("div", {
6317
6325
  class: `GPlaceCircle ${placeCircleLayout({
6318
- textAlign: textAlignRef.value
6326
+ textAlign
6319
6327
  })} ${gmapPlaceIconLayout({
6320
- textAlign: textAlignRef.value
6328
+ textAlign
6321
6329
  })}`
6322
6330
  }, `
6323
6331
  <img class="${placeIcon({
@@ -6331,13 +6339,14 @@ const GPlaceCircle = defineSetup(function GPlaceCircle2(props, {
6331
6339
  });
6332
6340
  const contentWithoutLabelRef = Vue.computed(() => {
6333
6341
  const {
6334
- hideIcon = false
6342
+ hideIcon = false,
6343
+ textAlign = DEFAULT_TEXT_ALIGN
6335
6344
  } = props;
6336
6345
  return createDom("img", {
6337
6346
  class: `GPlaceCircle ${placeIcon({
6338
6347
  hideIcon
6339
6348
  })} ${gmapPlaceIconLayout({
6340
- textAlign: textAlignRef.value
6349
+ textAlign
6341
6350
  })}`,
6342
6351
  src: imgPlaceCircle
6343
6352
  });
@@ -6386,7 +6395,7 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
6386
6395
  basePlace: Vue.toRef(props, "basePlace"),
6387
6396
  places: Vue.toRef(props, "places"),
6388
6397
  heightLimit: 9,
6389
- widthLimit: 32
6398
+ widthLimit: 34
6390
6399
  }));
6391
6400
  return () => {
6392
6401
  const {
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  import Vue, { defineComponent, h, computed, inject, provide, watch, onMounted, onUnmounted, watchPostEffect, shallowRef, ref, watchEffect, reactive, toRefs, toRef } from "vue";
8
8
  const style = "";
9
9
  const name = "@heycar/heycars-map";
10
- const version = "0.8.4";
10
+ const version = "0.8.5";
11
11
  const type = "module";
12
12
  const scripts = {
13
13
  dev: "vite -c vite.config.dev.ts",
@@ -6120,11 +6120,6 @@ const usePointsLabelDirection = (props) => {
6120
6120
  });
6121
6121
  directionsRef.value = directions;
6122
6122
  labeledPlacesRef.value = noOverlapPlaces;
6123
- console.log(
6124
- "usePointsLabelDirection basePlace, noOverlapPlaces = ",
6125
- basePlace.displayName,
6126
- noOverlapPlaces.map((item) => item.displayName)
6127
- );
6128
6123
  }
6129
6124
  );
6130
6125
  return { directionsRef, labeledPlacesRef, isContainBasePlaceRef };
@@ -6133,27 +6128,40 @@ function createLabelDirections(props) {
6133
6128
  const { sortedPoints, widthLimit, heightLimit, distanceFn } = props;
6134
6129
  const len = sortedPoints.length;
6135
6130
  const result = [];
6131
+ const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2) => {
6132
+ if (isLimited2)
6133
+ return reverse(prevDirection2);
6134
+ if (isDoubleLimited2 && prevDx2 < 0 && prevDirection2 === "left")
6135
+ return "left";
6136
+ return "right";
6137
+ };
6136
6138
  let prevDirection = "right";
6137
6139
  let isLimited = false;
6140
+ let isDoubleLimited = false;
6141
+ let prevDx = Infinity;
6138
6142
  for (let idx = 0; idx < len; idx++) {
6139
6143
  if (idx === len - 1) {
6140
- const direction2 = isLimited ? reverse(prevDirection) : "right";
6144
+ const direction2 = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6141
6145
  result.push(direction2);
6142
6146
  continue;
6143
6147
  }
6144
6148
  if (idx === 0) {
6145
6149
  const [dx2, dy2] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6146
6150
  isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6151
+ isDoubleLimited = dx2 > -widthLimit * 2 && dx2 < widthLimit * 2 && dy2 > -heightLimit && dy2 < heightLimit;
6147
6152
  const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6148
6153
  result.push(direction2);
6149
6154
  prevDirection = direction2;
6155
+ prevDx = dx2;
6150
6156
  continue;
6151
6157
  }
6152
6158
  const [dx, dy] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6153
- const direction = isLimited ? reverse(prevDirection) : "right";
6159
+ const direction = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6154
6160
  result.push(direction);
6155
6161
  prevDirection = direction;
6162
+ prevDx = dx;
6156
6163
  isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6164
+ isDoubleLimited = dx > -widthLimit * 2 && dx < widthLimit * 2 && dy > -heightLimit && dy < heightLimit;
6157
6165
  }
6158
6166
  return result;
6159
6167
  }
@@ -6162,7 +6170,8 @@ function filterNoOverlapPlaces(props) {
6162
6170
  const measureOverlap = (place1, place2) => {
6163
6171
  const [dx, dy] = distanceFn(place2point(place1), place2point(place2));
6164
6172
  const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6165
- console.log(
6173
+ spaceLog(
6174
+ "usePointsLabelDirection",
6166
6175
  "p1, p2, dx, dy, isOverlap = ",
6167
6176
  place1.displayName,
6168
6177
  place2.displayName,
@@ -6246,25 +6255,23 @@ var labelLayout = "fhyw8b";
6246
6255
  var labelStroke = "fhyw8d fhyw8c";
6247
6256
  var placeCircleLayout = createRuntimeFn({ defaultClassName: "fhyw80", variantClassNames: { textAlign: { left: "fhyw81", right: "fhyw82" } }, defaultVariants: {}, compoundVariants: [] });
6248
6257
  var placeIcon = createRuntimeFn({ defaultClassName: "fhyw88", variantClassNames: { hideIcon: { true: "fhyw89", false: "fhyw8a" } }, defaultVariants: {}, compoundVariants: [] });
6258
+ const DEFAULT_TEXT_ALIGN = "right";
6249
6259
  const APlaceCircle = defineSetup(function APlaceCircle2(props, {
6250
6260
  emit
6251
6261
  }) {
6252
- const textAlignRef = computed(() => {
6253
- var _a;
6254
- return (_a = props.textAlign) != null ? _a : "right";
6255
- });
6256
6262
  const contentRef = computed(() => {
6257
6263
  const {
6258
- hideIcon = false
6264
+ hideIcon = false,
6265
+ textAlign = DEFAULT_TEXT_ALIGN
6259
6266
  } = props;
6260
6267
  return `
6261
6268
  <div class="APlaceCircle ${placeCircleLayout({
6262
- textAlign: textAlignRef.value
6269
+ textAlign
6263
6270
  })}">
6264
6271
  <img class="${placeIcon({
6265
6272
  hideIcon
6266
6273
  })} ${amapPlaceIconLayout({
6267
- textAlign: textAlignRef.value
6274
+ textAlign
6268
6275
  })}" src="${imgPlaceCircle}">
6269
6276
  <div class="${labelLayout}">
6270
6277
  <div class="${labelStroke}">${props.label}</div>
@@ -6275,23 +6282,27 @@ const APlaceCircle = defineSetup(function APlaceCircle2(props, {
6275
6282
  });
6276
6283
  const contentWithoutLabelRef = computed(() => {
6277
6284
  const {
6278
- hideIcon = false
6285
+ hideIcon = false,
6286
+ textAlign = DEFAULT_TEXT_ALIGN
6279
6287
  } = props;
6280
6288
  return `<img class="APlaceCircle ${placeIcon({
6281
6289
  hideIcon
6282
6290
  })} ${amapPlaceIconLayout({
6283
- textAlign: textAlignRef.value
6291
+ textAlign
6284
6292
  })}" src="${imgPlaceCircle}">`;
6285
6293
  });
6286
6294
  const handleClick = () => {
6287
6295
  emit("click", props.position);
6288
6296
  };
6289
6297
  return () => {
6298
+ const {
6299
+ textAlign = DEFAULT_TEXT_ALIGN
6300
+ } = props;
6290
6301
  return h(AmapMarker, {
6291
6302
  "attrs": {
6292
6303
  "position": props.position,
6293
6304
  "content": props.label ? contentRef.value : contentWithoutLabelRef.value,
6294
- "anchor": textAlignRef.value === "left" ? AnchorType.middleRight : AnchorType.middleLeft,
6305
+ "anchor": textAlign === "left" ? AnchorType.middleRight : AnchorType.middleLeft,
6295
6306
  "zIndex": ZINDEX_PLACE_LAYER
6296
6307
  },
6297
6308
  "on": {
@@ -6303,19 +6314,16 @@ const APlaceCircle = defineSetup(function APlaceCircle2(props, {
6303
6314
  const GPlaceCircle = defineSetup(function GPlaceCircle2(props, {
6304
6315
  emit
6305
6316
  }) {
6306
- const textAlignRef = computed(() => {
6307
- var _a;
6308
- return (_a = props.textAlign) != null ? _a : "right";
6309
- });
6310
6317
  const contentRef = computed(() => {
6311
6318
  const {
6312
- hideIcon = false
6319
+ hideIcon = false,
6320
+ textAlign = DEFAULT_TEXT_ALIGN
6313
6321
  } = props;
6314
6322
  return createDom("div", {
6315
6323
  class: `GPlaceCircle ${placeCircleLayout({
6316
- textAlign: textAlignRef.value
6324
+ textAlign
6317
6325
  })} ${gmapPlaceIconLayout({
6318
- textAlign: textAlignRef.value
6326
+ textAlign
6319
6327
  })}`
6320
6328
  }, `
6321
6329
  <img class="${placeIcon({
@@ -6329,13 +6337,14 @@ const GPlaceCircle = defineSetup(function GPlaceCircle2(props, {
6329
6337
  });
6330
6338
  const contentWithoutLabelRef = computed(() => {
6331
6339
  const {
6332
- hideIcon = false
6340
+ hideIcon = false,
6341
+ textAlign = DEFAULT_TEXT_ALIGN
6333
6342
  } = props;
6334
6343
  return createDom("img", {
6335
6344
  class: `GPlaceCircle ${placeIcon({
6336
6345
  hideIcon
6337
6346
  })} ${gmapPlaceIconLayout({
6338
- textAlign: textAlignRef.value
6347
+ textAlign
6339
6348
  })}`,
6340
6349
  src: imgPlaceCircle
6341
6350
  });
@@ -6384,7 +6393,7 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
6384
6393
  basePlace: toRef(props, "basePlace"),
6385
6394
  places: toRef(props, "places"),
6386
6395
  heightLimit: 9,
6387
- widthLimit: 32
6396
+ widthLimit: 34
6388
6397
  }));
6389
6398
  return () => {
6390
6399
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",