Show text info for all markers, android google maps - android

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

Related

How to set margins for IconGenerator in Google Map utils?

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?

OSMBonuspack Custom KML marker appearing in wrong color

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,... ).

Show/hide point label Androidplot

When my chart gets a lot of data the point labels overlap each other and as a result I want to give the user an option to turn them off by clicking a button but I can't find anything in the documentation on how to do this. Below is how I setup the point labels when the chart is created.
BarFormatter series1Format = new BarFormatter(Color.rgb(51, 181, 229), Color.TRANSPARENT);'
PointLabelFormatter plf = new PointLabelFormatter();
plf.getTextPaint().setTextSize(18);
plf.getTextPaint().setColor(Color.BLACK);
series1Format.setPointLabelFormatter(plf);
Have you tried setting PointLabelFormatter to null inside your BarFormatter instance?
series1format.setPointLabelFormatter(null);
Then to turn the labels back on just add it back with your original method:
series1Format.setPointLabelFormatter(plf);
Now sure if this is the best way to turn on/off the point labels but if works :)
private void TogglePointLabelVisibility(boolean ShowLabels)
{
BarFormatter series1Format = new BarFormatter();
if(ShowLabels)
{
series1Format = new BarFormatter(Color.rgb(51, 181, 229), Color.TRANSPARENT);
PointLabelFormatter plf = new PointLabelFormatter();
plf.getTextPaint().setTextSize(18);
plf.getTextPaint().setColor(Color.BLACK);
series1Format.setPointLabelFormatter(plf);
}
else
{
series1Format.setPointLabelFormatter(null);
}
SeriesAndFormatterList<XYSeries, XYSeriesFormatter> renderer = plot.getSeriesAndFormatterListForRenderer(BarRenderer.class);
renderer.setFormatter(series1, series1Format);
}

android- how to put icon on google map api 2

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;
}

Android -- put space between tab title and icon?

This is obviously too close. Short of editing the icon file, how can I change it?
Code below is C# code (via Xamarin), but I'm sure I'll understand a Java answer just fine.
Android.App.ActionBar.Tab droidTab = this.ActionBar.NewTab();
droidTab.SetIcon(drawableBitmap);
droidTab.SetText(someString);
This is not possible using the default API. You can, however, set a custom view. Using a TextView with a compound Drawable, you can set the Drawable padding using setCompoundDrawablePadding:
TextView textView = new TextView(mContext);
textView.setText(someString);
textView.setCompoundDrawables(mDrawable, null, null, null);
textView.setCompoundDrawablePadding(mPaddingDp);
droidTab.setCustomView(textView);
Check the image
you can use the following code to achieve the spacing between icon and title
TextView tabOne = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.custom_tab, null);
tabOne.setText(tab1);
tabOne.setCompoundDrawablesWithIntrinsicBounds(R.drawable.dash_today,0, 0, 0);
tabOne.setCompoundDrawablePadding(icon_dp);
tabLayout.getTabAt(0).setCustomView(tabOne);
TextView tabTwo = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.custom_tab, null);
tabTwo.setText(tab2);
tabTwo.setCompoundDrawablesWithIntrinsicBounds(R.drawable.dash_pipe,0, 0, 0);
tabTwo.setCompoundDrawablePadding(icon_dp);
tabLayout.getTabAt(1).setCustomView(tabTwo);`

Categories

Resources