Google Maps Utils IconGenerator text styles and background - java

I just started using Google Maps Utils library so that I can have markers with text in them. I understand the library so far and I'm successfully using it. Code snippet:
IconGenerator icnGenerator = new IconGenerator(this);
Bitmap iconBitmap = icnGenerator.makeIcon(item.placeItemName);
myPlaceItemMarkers.add(mMap.addMarker(new MarkerOptions().position(new LatLng(item.latitude, item.longitude))
.icon(BitmapDescriptorFactory.fromBitmap(iconBitmap)).anchor(0.5f, 0.6f)));
Now I started playing around with styling the window a bit and there are two functions that interest me in particular:
icnGenerator.setBackground(Drawable background);
icnGenerator.setTextAppearance(int resid);
I looked up for info on docs and there's only info for BubbleIconFactory which is deprecated. Could someone tell me how to use these 2 functions? I know setTextAppearance is for changing text style but how do I do it? And if I'm not wrong setBackground is for setting custom marker background, but I don't know how to use that either.

I'm still not completely sure how to use setBackground() because I tried using Drawables but it wouldn't work but I figured out how to use setTextAppearance().
I just made a new style:
<style name="iconGenText">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#000000</item>
</style>
And then applied it to IconGenerator:
IconGenerator icnGenerator = new IconGenerator(this);
icnGenerator.setTextAppearance(R.style.iconGenText);
It works as it should.

Set the background like this:
IconGenerator icnGenerator = new IconGenerator(this);
icnGenerator.setBackground(getResources().getDrawable(R.drawable.marker_background));
marker_background has to be a .9.png file. Like the drawables of the library.
It works pretty good for me.

if you're just wanting to change away from the default marker styling without getting fancy you can do this.
icnGenerator.setStyle(IconGenerator.STYLE_BLUE)
There's currently 7 basic styles to select from:
IconGenerator.STYLE_BLUE
IconGenerator.STYLE_DEFAULT
IconGenerator.STYLE_GREEN
IconGenerator.STYLE_ORANGE
IconGenerator.STYLE_PURPLE
IconGenerator.STYLE_RED
IconGenerator.STYLE_WHITE
doc: https://www.javadoc.io/doc/com.google.maps.android/android-maps-utils/latest/com/google/maps/android/ui/IconGenerator.html

Related

Material slider's setTickActiveTintList is not working

I am trying to create a ColorStateList programatically using this:
ColorStateList stateList = ColorStateList.valueOf(Color.RED);
to pass in setTickActiveTintList method
slider.setTickInactiveTintList(stateList);
But seems above code is not working. and I want to do it programmatically not in XML.
I am using material version : 1.0.0
Can somebody please explain me how to create this ?

How to change the color of this custom progress bar using Java instead of using XML?

I'm a beginner to Android and Java. I have some trouble setting this custom loading animation I found on GitHub. https://ybq.github.io/Android-SpinKit/.
I've implemented it directly in to my code using Java as below and it works.
progressBar = findViewById(R.id.progressBar);
Sprite threeBounce = new ThreeBounce();
progressBar.setIndeterminateDrawable(threeBounce);
But I want to change the color of it from code without using XML. Your help is greatly appreciated.
Fortunately this Library offers a method called setColor.
You can use this code, the progressBar will be blue then:
SpinKitView progressBar = findViewById(R.id.progressBar);
Sprite threeBounce = new ThreeBounce();
threeBounce.setColor(Color.BLUE);
progressBar.setIndeterminateDrawable(threeBounce);

How to make the StatusBar transparent on Android4.2

It is knowed that the StatusBar is black default of Andriod 4.2.
However,I want to make the StatusBar transparent on Launcher and change to be black when it come into an activity. And then,when it come back to the Launcher,the StatusBar recover to transparent.
There is a way to implement,but it do not work perfectly(the Activity open firstly and the StatusBar turn transparent slowly,No strict synchronization).
set "status_bar_background" to be #00000000;
delete the code "mStatusBarWindow.setBackground(null);" which in method "makeStatusBarView()" of PhoneStatusBar.java;
Edit mPixelFormat = PixelFormat.OPAQUE to mPixelFormat = PixelFormat.TRANSLUCENT;
change the code in WindowStateAnimator.java
updateSurfaceWindowCrop(), after the code line
"applyDecorRect(mService.mSystemDecorRect);"
Added:
if(w.mAttrs.type == LayoutParams.TYPE_WALLPAPER) {
w.mSystemDecorRect.top = 0;
}
I think cannot change StatusBar. If you want change, you has to change SystemUI
. You can references via link: http://forum.xda-developers.com/showthread.php?t=2366476
Hide the status bar and use you own header instead of it, best Solution.

Offline tile caching using MapBox Android SDK

I have a working iOS prototype using the iOS tile-caching technique as shown below (Objective-C code):
RMTileCache * tileCache = [[RMTileCache alloc] initWithExpiryPeriod:0];
[tileCache setBackgroundCacheDelegate:self];
RMMapboxSource * tileSource = [[RMMapboxSource alloc] initWithMapID:mapID];
[tileCache beginBackgroundCacheForTileSource:tileSource southWest:southWest northEast:northEasth minZoom:minZoom maxZoom:maxZoom];
What this basically does is download the map, cache the tiles permanently and make it possible for the app to run offline in the future. Since we're going through the official payed API, this is of course not violating any of the legal restrictions.
Now I'd like to achieve the same on Android. I have the SDK running in Android Studio and a working project with a remote map using the Map ID, basically this (Android Eclipse layout XML):
<com.mapbox.mapboxsdk.views.MapView
android:id="#+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
mapid=“my_map_id" />
This works fine, but the solution has to be completely offline once the caching is done. My question is: is there a Java equivalent of the iOS source code above in the MapBox SDK? I attempted to look in the API, but could not find a solid reference to the tile caching system. And after some painful time trying to get it running based on the method names and code documentation, I gave up.
I'm running the latest GitHub distribution of MapBox along with the latest Android Studio, everything's up and running fine, but can't find the code to accomplish this. I don’t necessarily need an API reference, a few lines of code showing how it’s done would be enough.
Offline Tile Caching support is now available in the Mapbox Android SDK as of version 0.5.1. It was released on 20-December-2014. Here's a basic example of how to get started:
OfflineMapDownloader offlineMapDownloader = OfflineMapDownloader.getOfflineMapDownloader(getActivity());
BoundingBox boundingBox = mapView.getBoundingBox();
CoordinateSpan span = new CoordinateSpan(boundingBox.getLatitudeSpan(), boundingBox.getLongitudeSpan());
CoordinateRegion coordinateRegion = new CoordinateRegion(mapView.getCenter(), span);
offlineMapDownloader.beginDownloadingMapID("MapboxMapID", coordinateRegion, (int) mapView.getZoomLevel(), (int) mapView.getZoomLevel());
To load a previously saved map:
ArrayList<OfflineMapDatabase> offlineMapDatabases = offlineMapDownloader.getMutableOfflineMapDatabases();
OfflineMapDatabase db = offlineMapDatabases.get(0);
OfflineMapTileProvider tp = new OfflineMapTileProvider(getActivity(), db);
offlineMapOverlay = new TilesOverlay(tp);
mapView.addOverlay(offlineMapOverlay);
I asked this question to the support team, here's the answer:
"We don't currently have a release date for the Android SDK or for this feature, because both are in very early stages of development.
--
Tom MacWright
support#mapbox.com"
It's a very good product, I hope we can use it soon in Android.
In your layout file there must be:
<com.mapbox.mapboxsdk.views.MapView
android:id="#+id/yourMapViewId"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
In code where you want to initialize MapView:
File file = new File("your full path to tiles db");
MBTilesLayer mbTilesLayer = new MBTilesLayer(file);
MapView mapView = (MapView) findViewById(R.id.yourMapViewId);
mapView.setTileSource(mbTilesLayer);

"setImageDrawable(Drawable.createFromPath)" get image from web server Android

I am using the the gridView example from the developer.android.com site. But they are using images saved in the res/drawable folder. I want to try and set the images to come from my web server.
private Integer[] mThumbIds={
for(int i=0;i<myJSONArray.lenght();i++){
Object[] myJSONArray;
setImageDrawable(Drawable.createFromPath(String "www.mywebsite.com: + myJSONArray[i]).thumb);
};
};
Am I on the correct path to accomplish this? I am looking for advice or documentations/tutorials on this process. Thanks in advance.
I modified the GreenDroid library to do it for me - it has a nice set of imageloading classes. It takes some slight modification if you don't want to use their actionbar (I didn't see an easy way to do it without modification). Everything is also async : D !
this way you cant create Drawable from internet, for that you have first download content & make it Drawable refer this

Categories

Resources