maplibre-react-native icon indicating copy to clipboard operation
maplibre-react-native copied to clipboard

MGLSymbolStyleLayer incorrect scale in release build

Open ferologics opened this issue 2 years ago • 1 comments
trafficstars

Steps to Trigger Behavior

  1. create a MGLSymbolStyleLayer with some image
  2. observe image size differs based on build configuration

Minimal Reproducible Example

const point_icon = require('@assets/icons/point/Group.png');
<MapLibreGL.SymbolLayer id={id + '_layer'} style={{   iconImage: point_icon }} />

where @assets/icons/point/Group.png has [email protected] and [email protected] variants point_asset_image.zip

Expected Behavior

Image stays same size as in debug build

Actual Behavior

Image is @3x.png scale size instead

Screenshots (if applicable)

release debug
IMG_2910 image

Version(s) affected

  • Platform: iOS
  • OS version: 16.4.1
  • Device type: iPhone 14 Pro Max
  • Development OS: macOS 13.3.1 (22E261)
  • maplibre-react-native Version 9.0.1
  • React Native Version: 0.71.6

Additional context

Maybe related to https://github.com/facebook/react-native/issues/28670

ferologics avatar Apr 18 '23 18:04 ferologics

workaround: remove @2 and @3 scales of the asset, make the @3 size default, but multiply iconSize by 0.3. image

ferologics avatar Apr 19 '23 07:04 ferologics

I've created these assets:

Image Image Image

And tested with this example:

import {
  MapView,
  ShapeSource,
  SymbolLayer,
} from "@maplibre/maplibre-react-native";
import { Image } from "react-native";

import image from "../assets/images/example.png";

export function BugReport() {
  return (
    <>
      <Image source={image} />
      <MapView style={{ flex: 1 }}>
        <ShapeSource id="shape" shape={{ type: "Point", coordinates: [0, 0] }}>
          <SymbolLayer id="symbol" style={{ iconImage: image }} />
        </ShapeSource>
      </MapView>
    </>
  );
}

Tested with debug and release builds:

Debug Release
Image Image
Image Image

When measuring the images they are both inside and outside the map in the corresponding pixel ratio size. I guess this is fixed by any of the previous upgrades.

KiwiKilian avatar Mar 15 '25 11:03 KiwiKilian