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