Skip to content

How do you set the size for a Marker? #3455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
codingdudecom opened this issue Jun 3, 2020 · 4 comments
Closed

How do you set the size for a Marker? #3455

codingdudecom opened this issue Jun 3, 2020 · 4 comments

Comments

@codingdudecom
Copy link

Question

I have a marker like this:

            <Marker
              title={marker.key}
              image={mapPinImg}
              key={marker.key}
              coordinate={marker.coordinate}
              style={styles.marker}
            ></Marker>

const styles = StyleSheet.create({
  marker: { width: 160 },
});

But the width property does not do anything. I tried also using a larger image for the marker, but that's not working either.

What's the correct way for setting the size for the markers?

thanks!
John

@pROFESOR11
Copy link

Hi @codingdudecom ,
try this:

<Marker ...>
 <Image style={{ width: 160, height: 160 }} />
</Marker>

@codingdudecom
Copy link
Author

Thanks! it works

I used resizeMode: "contain" because the image was cropped. And also I had to set the same size on the Marker too because the placement of the marker was not correct

<Marker style={{width: 48, height: 48}}>
        <Image
                      source={require("../assets/map-pin.png")}
                      style={{ width: 48, height: 48, resizeMode: "contain" }}
                    />
</Marker>

@rajanAndroapps
Copy link

Just put the svg or image icon inside tag also give width and height to Svg

@abhion
Copy link

abhion commented Feb 21, 2025

Hi @codingdudecom , try this:

<Marker ...>
 <Image style={{ width: 160, height: 160 }} />
</Marker>

this didn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants