I been using google map utils for a couple of days now and it seemed so fine.
This is code im using to add a marker with a custom layout file to the map.
IconGenerator mIconGenerator = new IconGenerator(getApplicationContext());
View mView = getLayoutInflater().inflate(R.layout.map_location_label, null);
TextView mInfoWindowText = (TextView) mView.findViewById(R.id.location);
mInfoWindowText.setText(Takzy.pickupLocationText);
mIconGenerator.setContentView(mView);
mIconGenerator.setRotation(-90);
mIconGenerator.setContentRotation(90);
mIconGenerator.setContentPadding(0, 0, 0, 0);
view.Bitmap mBitmapPickupLocation = mIconGenerator.makeIcon();
Bitmap mBitmapDestinationLocation = mIconGenerator.makeIcon(Takzy.destinationLocationText + " >");
// add the pickup marker to map
mMap.addMarker(
new MarkerOptions().title(Takzy.pickupLocationText)
.position(Takzy.pickupLatLng)
.icon(BitmapDescriptorFactory
.fromBitmap(mBitmapPickupLocation))
.anchor(mIconGenerator.getAnchorU(), mIconGenerator.getAnchorV()));
Everything is okay but as you can see, my text gets cut from the marker label. I have tried googling, read the docs over and over, and none of them worked.
it will work fine if I do not rotate the marker. but I need my marker rotated.
Can someone point out what might be the issue is?
Related
i'm trying to show text for all markers.
I've seen this solution:
http://googlemaps.github.io/android-maps-utils/
And checked the
http://googlemaps.github.io/android-maps-utils/javadoc/
I've succeeded to get to this situation:
But as you can see the text is on the icon, and I want it to have a bit of margin button - and I can't figure out how to do it.
This is the code I used to make the marker:
Context context = getApplicationContext();
TextView text = new TextView(context);
text.setText(pilotName);
text.setTextSize(18);
text.setTypeface(null, Typeface.BOLD);
text.setTextColor(getResources().getColor(R.color.colorBlack));
IconGenerator generator = new IconGenerator(context);
generator.setContentPadding(20,20,0,0);
generator.setBackground(context.getDrawable(R.drawable.aircraft));
generator.setContentView(text);
Bitmap icon = generator.makeIcon();
MarkerOptions tp = new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromBitmap(icon));
mMap.addMarker(tp);
I've also tried: text.setPadding(40, 40, 0, 0);
And generator.setContentPadding(20,20,0,0);
to see if it solves it... and it didn't work
How can I solve it? Thanks
I am trying to animate change marker position in Xamarin android Google Map
var markerWithIcon = new MarkerOptions();
markerWithIcon.SetPosition(new LatLng(e.Latitude, e.Longitude));
var marker = googleMap.AddMarker(markerWithIcon);
Setting its position
marker.Position = new LatLng(e.Latitude, e.Longitude);
How to change position with linear animation? Thanks in advance.
I've been trying to change the style of my KML so KmlPoint would be represented with a custom marker of my choice.
Here are the markers I'm using:
I successfully made the wanted points show up with the respective markers, but they look like a color filter might be applied to them or the bitmap is simply corrupted and I don't know why.
Here is my code:
KmlDocument dryKmlDocument = new KmlDocument();
File f2 = new File(appPath + "/dry_hydrant.kml");
dryKmlDocument.parseKMLFile(f2);
Bitmap blueBitmap = ((BitmapDrawable)ResourcesCompat.getDrawable(getResources(), R.drawable.blue, null)).getBitmap();
Style dryStyle = new Style(blueBitmap, 0x901010AA, 1.0f, 0x20AA1010);
ZoneStyler dryZoneStyler = new ZoneStyler(dryStyle, dryKmlDocument, osmView);
dryKmlOverlay = (FolderOverlay)dryKmlDocument.mKmlRoot.buildOverlay(osmView, null, dryZoneStyler, dryKmlDocument);
KmlDocument fireKmlDocument = new KmlDocument();
File f3 = new File(appPath + "/fire_hydrant.kml");
fireKmlDocument.parseKMLFile(f3);
Bitmap redBitmap = ((BitmapDrawable)ResourcesCompat.getDrawable(getResources(), R.drawable.red, null)).getBitmap();
Style fireStyle = new Style(redBitmap, 0x00000000, 1.0f, 0x00000000);
ZoneStyler fireZoneStyler = new ZoneStyler(fireStyle, fireKmlDocument, osmView);
fireKmlOverlay = (FolderOverlay)fireKmlDocument.mKmlRoot.buildOverlay(osmView, null, fireZoneStyler, fireKmlDocument);
Can someone point me to what could be causing this?
EDIT: Imgur didn't want to show up my bmp marker images so I took a screenshot in windows explorer instead.
Use PNG format, and ensure the corners are fully transparent (you cannot do that with the Windows Paint, you need something like IcoFX, Gimp, PhotoShop,... ).
I need to add icon to my map, something like image below :
this is my code :
MarkerOptions marker = new MarkerOptions().position(location).title("resturan")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.a2));
I manage to add icon to my map but it's just an icon with no border and it doesn't look nice , in the above image , there is a border around each image , this is what i need
How can I add this border to my icons ?
thank you
Take a look at this blog post I wrote on how to put images inside the InfoWindow in an asynchronous way:
Guide: Google Maps V2 for Android : Update InfoWindow with an Image Asynchronously
You can see there how to specify a layout for your InfoWindow as well, in the layout you could add the borders to your image using the margins attribute.
This way you can customize your map icon before apply in the map.
public Bitmap createDrawableFromView(Context context) {
View marker = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).
inflate(R.layout.map_popup, your_parent_layout,false);
TextView tv_location_name = (TextView) marker.findViewById(R.id.tv_location_name);
TextView tv_event_status = (TextView) marker.findViewById(R.id.tv_event_status);
TextView tv_event_name = (TextView) marker.findViewById(R.id.tv_event_name);
DisplayMetrics displayMetrics = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
marker.measure(displayMetrics.widthPixels, displayMetrics.heightPixels);
marker.layout(0, 0, displayMetrics.widthPixels, displayMetrics.heightPixels);
marker.buildDrawingCache();
Bitmap bitmap = Bitmap.createBitmap(marker.getMeasuredWidth(), marker.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
marker.draw(canvas);
return bitmap;
}
I use osmdroid which is based on Google Map API v1. When I zoom in/out the map my markers are scaling accordingly but I want them to have fixed size. So how can I prevent scaling of a Drawable (used as a marker of OverlayItem) when I zoom in/out the map?
I create Drawable for the marker using BitmapDrawable(scaledBitmap)
for fix size u add a popupview on a geopoint which is fix size by setting view params and set this drawable as a background
View popUp = getLayoutInflater().inflate(R.layout.map_popup, map, false);
MapView map = (MapView) findViewById(R.id.mapview);
MapView.LayoutParams mapParams = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT,
<geopoint>,
<x offset if required>,
<y offset like pinHeight>,
MapView.LayoutParams.BOTTOM_CENTER);
map.addView(popUp, mapParams);