@evergis/react 4.0.79 → 4.0.80

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.js CHANGED
@@ -5185,6 +5185,7 @@ const loadSvgAsImage = (url, size, pixelRatio) => {
5185
5185
  * ```
5186
5186
  */
5187
5187
  const useMapImages = ({ images }) => {
5188
+ const { api } = useGlobalContext();
5188
5189
  const { map, loaded: mapLoaded } = useMapContext();
5189
5190
  const [loaded, setLoaded] = React.useState(false);
5190
5191
  const [errors, setErrors] = React.useState({});
@@ -5212,6 +5213,22 @@ const useMapImages = ({ images }) => {
5212
5213
  const size = config.size ?? 64;
5213
5214
  const pixelRatio = config.pixelRatio ?? 1;
5214
5215
  const sdf = config.sdf ?? false;
5216
+ // Картинка из каталога
5217
+ if (!config.url.startsWith("data:image") && !config.url.startsWith("http")) {
5218
+ try {
5219
+ const { data } = await loadSvgAsImage(URL.createObjectURL(await api.catalog.getFile(config.url)), size, pixelRatio);
5220
+ map.current.addImage(config.name, data, {
5221
+ sdf,
5222
+ pixelRatio,
5223
+ });
5224
+ loadedImagesRef.current.add(config.name);
5225
+ }
5226
+ catch (error) {
5227
+ const message = error instanceof Error ? error.message : "Unknown error";
5228
+ setErrors(prev => ({ ...prev, [config.name]: message }));
5229
+ throw error;
5230
+ }
5231
+ }
5215
5232
  if (isSvgUrl(config.url)) {
5216
5233
  // SVG: растеризуем через canvas
5217
5234
  try {