Google MapsActivity: Tileoverlay set attribution - java

Mapbox TileOverlays require attribution. How can I set this in java?
Here is my code to change the tileOverlay to a custom one. The attribution I have to use is this link: http://www.openstreetmap.org/copyright
overlayString = "http://a.tile.openstreetmap.org/{z}/{x}/{y}.png";
provider = new CustomUrlTileProvider(256, 256, overlayString);
mSelectedTileOverlay = gMap.addTileOverlay(new TileOverlayOptions().tileProvider(provider).zIndex(-1));

I'd suggest using a Textview the sits on top on the mapview and has a clickable url to the copyright link

Related

Is it possible to refer a local class for custom tile map on android?

I need to link a local java class which has my custom tile server path declared instead of referring TileSourceFactory.java through OSM jar files or via online.
MapView map = (MapView) findViewById(R.id.map);
map.setTileSource(TileSourceFactory.MAPNIK);
[LINK] https://github.com/osmdroid/osmdroid/wiki/How-to-use-the-osmdroid-library#main-activity
I guess this should be easy (I don`t have a practice with online source yet)
XYTileSource tileSource =
new XYTileSource("Name of Your map", MIN_ZOOM_LEVEL, MAX_ZOOM_LEVEL,
256, ".png", new String[]{your server urls});
map.setTileSource(tilesSource);

How to set an Icon in Android using URL

I am using the WeatherOpenMap API in my app in order to get weather information about several cities.
For example, if you have "broken clouds" as a weather condition, then the weatherFont icon changes to light blue.
if (weather_description.equals("BROKEN CLOUDS"))
weatherIcon.setTextColor(Color.parseColor("#0489B1")); // light blue
I am using Typeface:
weatherFont = Typeface.createFromAsset(getApplicationContext().getAssets(), "fonts/weathericons-regular-webfont.ttf");
weatherIcon.setTypeface(weatherFont);
But now, I don't want to use this ttf file for my weatherIcon, I want to use hyperlinks, because it looks much better, so such as:
http://openweathermap.org/img/w/10d.png
which stands for moderate rain. But as you can see, this is an URL, how can I use this URL to change my weatherFont Icon when I have "moderate rain" as weather condition?
Thank you
You could use an image loading library like Picasso or Volley. Using Picasso, the code would look something like this:
String iconUrl = "https://...";
ImageView imgWeatherIcon = view.findViewById(R.id.imgWeatherIcon);
Picasso.with(context).load(iconUrl).into(imgWeatherIcon, new Callback()...

JxMaps possibility to disable Google's default POI

with JxMaps I can show a Google-Map window within Java Swing.
When zooming in, Google shows much details as Restaurants and Shops.
I also can click on those Restaurants and Shops - but that's something I don't want to have in my application.
Anyone having an idea on how to disable it?
I think it might be possible when setting map options:
// Getting the associated map object
map = getMap();
// Creating a map options object
MapOptions mapOptions = new MapOptions();
// Creating a map type control options object
MapTypeControlOptions controlOptions = new MapTypeControlOptions();
// Changing position of the map type control
controlOptions.setPosition(ControlPosition.TOP_RIGHT);
// Setting map type control options
mapOptions.setMapTypeControlOptions(controlOptions);
// Setting map options
map.setOptions(mapOptions);
But I cant find an appropriate option.
Thank you very much
MapOptions doesn't have property that allows to hide POI. But you can create custom map style with hidden default POI. Please take a look example below:
MapTypeStyler styler = new MapTypeStyler();
styler.setVisibility("off");
MapTypeStyle style = new MapTypeStyle();
style.setElementType(MapTypeStyleElementType.ALL);
style.setFeatureType(MapTypeStyleFeatureType.POI);
style.setStylers(new MapTypeStyler[]{styler});
StyledMapType styledMap = new StyledMapType(map, new MapTypeStyle[]{style});
map.mapTypes().set("newStyle", styledMap);
map.setMapTypeId(new MapTypeId("newStyle"));

how can I right-align activity titles?

I'm new to android development and I need proper instructions to right-align activity titles in a min-sdk:8 android application. I can do so by enabling rtl support for my app, but that only takes effect when the user has chosen an rtl language on his/her device. is there a way to force rtl even when the device language is ltr? or any other instructions to right-align titles in ltr mode? thx.
You can set a custom view in your Toolbar like this:
(copied from How to align center the title or label in activity?)
TextView customView = (TextView)
LayoutInflater.from(this).inflate(R.layout.actionbar_custom_title_view_centered,
null);
ActionBar.LayoutParams params = new ActionBar.LayoutParams(
ActionBar.LayoutParams.MATCH_PARENT,
ActionBar.LayoutParams.MATCH_PARENT, Gravity.RIGHT );
customView.setText("Some centered text");
getSupportActionBar().setCustomView(customView, params);
You can do that^. If you were do that multiple times in your app, you can create a customToolbar class that extends Toolbar and overwrite this method and add all that code there^ (and use that custom toolbar in your xml as well)
https://developer.android.com/reference/android/widget/Toolbar.html#generateLayoutParams(android.util.AttributeSet)

Add custom View as marker in Google Maps API v2

I've developed a class that inherits from a View class and I want it to serve as a marker on a MapFragment/MapView from a Google Maps API v2. As I recall, such thing was possible in API v1 and even now it is possible on iOS. I'm looking for something like this:
MapView map = (MapView)findViewById(R.id.mapview);
CircleTimerView myTimer = new CircleTimerView(this);
LayoutParams lp = new LayoutParams(iv.getWidth(), iv.getHeight(), geoPoint, LayoutParams.BOTTOM);
map.addView(myTimer,lp);
My custom View is animated and it is a key feature of my app.
My question is: Is it possible for a current state of Google Maps API? Or should I try to obtain API v1 key and work with something that was deprecated?
Thanks in advance for your replies.
should I try to obtain API v1 key and work with something that was deprecated?
You cannot obtain new keys for API v1.
My custom View is animated and it is a key feature of my app.
You cannot have animated Marker icon unless you repeatedly change the icon using Marker.setIcon.
Is it possible for a current state of Google Maps API?
You can use a View as icon if you draw it into a Bitmap first.
This library from Chris Broadfoot can greatly help you with that task:
https://github.com/googlemaps/android-maps-utils
See this video for what the lib can do: http://www.youtube.com/watch?v=nb2X9IjjZpM
Or the new website: http://googlemaps.github.io/android-maps-utils/
in order to customize / use your own custom maker on google maps api v2 you could write the code as follows:
in onCreate declare the marker:
userIcon = R.drawable.red;
and then i used it where you need it, in my case i used it in a method:
if(userMarker!=null) userMarker.remove();
userMarker = theMap.addMarker(new MarkerOptions()
.position(lastLatLng)
.title("You are here")
.icon(BitmapDescriptorFactory.fromResource(userIcon))
.snippet("Your last recorded location"));
theMap.animateCamera(CameraUpdateFactory.newLatLng(lastLatLng), 100, null);
CameraUpdate center=
CameraUpdateFactory.newLatLng(lastLatLng);
CameraUpdate zoom=CameraUpdateFactory.zoomTo(15);
theMap.moveCamera(center);
theMap.animateCamera(zoom);
hope this helped. good luck
i had the same issue these days and you should do the switch for v2 as you can do all the same stuff from v1 easier + many new features.
MapView has been replaced with the new GoogleMap-Objecttype.
A very detailed and decent Tutorial site can be found HERE!

Categories