Reputation: 327
How do I set the marker size. Can anyone tell me?
Upvotes: 6
Views: 7705
Reputation: 99
use Marker this way
<Marker
anchor={{ x: 0.5, y: 1}}
coordinate={location}
>
<Image style={styles.marker} source={image} />
</Marker>
Upvotes: 1
Reputation: 4908
I assume you have a bmp
image since you are setting a custom marker.
To resize the bmp
, use Bitmap.createScaledBitmap (Bitmap src, int width, int height, boolean filter)
Upvotes: 1
Reputation: 1121
It's happening because the icon you are using as a marker is bigger in size.So,You can first convert it into Bitmap and change its size and then use that bitmap in as a custom marker. For example I have made a method which resizes your bitmap and returns the resized bitmap.
public Bitmap resizeBitmap(String drawableName,int width, int height){
Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(),getResources().getIdentifier(drawableName, "drawable", getPackageName()));
return Bitmap.createScaledBitmap(imageBitmap, width, height, false);
}
Then call this method in googleMap.addMarker()
googleMap.addMarker(new MarkerOptions()
.title("New Marker").position(yourGivenPosition).icon(BitmapDescriptorFactory.fromBitmap(resizeBitmap("your drawable name",72,64))));
Upvotes: 7
Reputation: 1264
Change the dimensions of your Marker image (icon), 30 x 40 it's ok I think
Upvotes: 1