Google maps android custom images - android

I have a specific problem with Google Maps for Android. I should be able to make Google Maps look like the map on this page www.bam.brno.cz, but I'm new to Goole Maps for Android so I don't know if there's a way to do it.
I don't have any of those map images, but i guess there should be a way to get it from the internet (like WMS or something). If I was eventually able to save them and use them offline that would be great, but if not and the app would have to use data connection, it's also ok.
I already got app with google maps, so the question is just about how to get the map images and replace default google maps images.
Also if that wouldn't be posible, I would like to know what other options I have(like if theres some other map images I can use and how)
PS: not sure how it's called correctly: map images/map tiles
EDIT: I don't care about the objects, I know how to do them. I don't know how to get the whole map, the tiles it's made from. I'm already familiar with markers and camera moving etc.

Yes you can use marker for same.
You can try some thing like ..
m = myMap.addMarker(new MarkerOptions()
.position(new LatLng(startLatLng.latitude, startLatLng.longitude))
.title("Vivek Test"));
Here m is Marker;
and myMap is GoogleMap
Complete structure like this ..
myMap = ((SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map)).getMap();
//myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
myMap.setMyLocationEnabled(true);
myMap.moveCamera(CameraUpdateFactory.newLatLng(startLatLng));
myMap.animateCamera(CameraUpdateFactory.zoomTo(20), 2000, null);
m = myMap.addMarker(new MarkerOptions()
.position(new LatLng(startLatLng.latitude, startLatLng.longitude))
.title("Vivek Test"));
Hope it helps. Cheers!

There is at least one file holding a series of coordinates (Latitude, Longitude) of each of the colored lines. Get those coordinates and use Polylines. These should take care of the colored lines. The grey dots would be Markers and these could be in the same file. Assuming that GoogleMaps has similar places names, then with these two you ought to be able to reproduce the map.

Related

Offline navigation with Mapbox Sdk in Android app from Kml

I'm trying to develop an offline navigation app for Trekking.
The app shows to the user a list of nearby track/routes where he can go.
Examples:
-Walking to Etna Vulcan
-Walking in the wood.
I've several KML files provided to me by local guides, each one for a different track.
So, if i choose "Walking to Etna Vulcan", I will have a Map with the track that I've to follow to go the Etna Vulcan, with some markers of interesting point (Examples: Refuges, Monuments). This data is actually ready, in KML format.
So:
The user chooses the track from the list that I provide, then the phone shows the track on the map(from kml or equivalent) with the current user position.
I'm doing it with MapBox sdk (but i'm open to alternatives).
Actually, I've successfully downloaded an offline map of the zone (Sicily), but i'm note sure how to write my kml on the map.
I also imported a kml in Mapbox Studio, but i don't know how to download a MapBox Studio Map into my application.
Thank you for your time!
If Mapbox seems like a good alternative then you just need to study their Android SDK to see if and how drawing markers and coordinate tracks are supported.
For the tracks see https://www.mapbox.com/android-sdk/geojson/
The relevant (to you) part is right at the end of their example code:
LatLng[] pointsArray = points.toArray(new LatLng[points.size()]);
// Draw Points on MapView
mapboxMap.addPolyline(new PolylineOptions()
.add(pointsArray)
.color(Color.parseColor("#3bb2d0"))
.width(2));
Here they have the coordinate points in the points ArrayList. They have been extracted from GeoJSON data, but you would just need to extract the coordinate points from the KML data and then draw the track based on that example.
For markers see https://www.mapbox.com/android-sdk/marker/
They have this example code:
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(48.13863, 11.57603))
.title("Hello World!")
.snippet("Welcome to my marker."));
For a marker with a custom icon see https://www.mapbox.com/android-sdk/custom-marker-icon/
They have this example code:
// Create an Icon object for the marker to use
IconFactory iconFactory = IconFactory.getInstance(MainActivity.this);
Drawable iconDrawable = ContextCompat.getDrawable(MainActivity.this, drawable.ic_directions_boat_black_18dp);
Icon icon = iconFactory.fromDrawable(iconDrawable);
// Add the custom icon marker to the map
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(-33.8500000, 18.4158234))
.title("Cape Town Harbour")
.icon(icon));
So you would just use a regular Android Drawable for the custom icon.
Looks quite convenient. I haven't used the Mapbox SDK myself.

Android Google Map multiple markers on same location

I have a simple app with Google Map and dynamicly loading markers. In case 2 or more markers have same lat and long only one is presented. Is there any solution for this? This is how I plot markers to map
private void plotMarkers(ArrayList<MyMarker> markers, String markerIcon)
{
if(markers.size() > 0)
{
for (MyMarker myMarker : markers)
{
// Create user marker with custom icon and other options
// Toast.makeText(getApplicationContext(), myMarker.getmLatitude().toString(), Toast.LENGTH_SHORT).show();
MarkerOptions markerOption = new MarkerOptions().position(new LatLng(myMarker.getmLatitude(), myMarker.getmLongitude()));
markerOption.icon(BitmapDescriptorFactory.fromResource(manageMarkerIcon(markerIcon)));
Marker currentMarker = mMap.addMarker(markerOption);
mMarkersHashMap.put(currentMarker, myMarker);
mMap.setInfoWindowAdapter(new MarkerInfoWindowAdapter());
}
}
}
Even if you could, how would you use these two overlapping markers? only the top one would be visible.
Instead, if two markers overlap, you could express the data they share in one marker that contains them both.
this answer might assist: Android Google Maps v2 - Add object to marker
Both markers are shown, but both on the same location and it seems to be only one, and if you click on them, only one info window will be presented.
If you really need to add two markers at the same location you may want to take a look at Google Maps Android Marker Clustering Utility. It's part of the Google Maps Android API Utility Library.
A possible workaround could be to check if there is another marker in the position you are trying to draw the marker into, and if so, move the new marker a little bit appart.

Load a custom google map to android

I'm new to android development.
I need to load a custom google-map someone made in google maps (a map with marks and information).
My question is how to load this map on a android app (and not just creating a new map and manually adding all the markers and information -- because than each time client wants to change something in the map he will need to change it in 2 places).
I know i can just make a webview but than i can't access the location and focus on users location -- is there any other way?
Thanks for the help!
You can take the location of your indicated region and add the markers manually if there isn't place to mark.
static final LatLng MELBOURNE = new LatLng(-37.813, 144.962);
Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
https://developers.google.com/maps/documentation/android-api/marker

Want to create google map navigation in my application - custom way

I have created an application in which I am trying to show user's movement by animating marker position.
Using Google map V2.
Location updates using location client.
Animating marker using new location.
But comparing with Google map navigation, there is no continuity in rendering navigation.
Can anyone suggest a better approach? Thanks!
For continuity, I think you need to fetch regular location updates from location client by giving location request like this.
LocationRequest request = LocationRequest.create()
.setInterval(0).setFastestInterval(0)
.setSmallestDisplacement(0)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
Then for smooth animation you can follow the approach Steve Benett mentioned. here
The last case you mentioned in the comment about the path. I also had the same issue in one of my app. I tried with gps route simulator app to mock a route. then comparing my app and google map, googlemap followed the correct road path while my app's marker was moving slightly shifted from road. Then I tried some tweaks with marker. Like this
mPositionMarker = mMap.addMarker(new MarkerOptions()
.flat(true)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.positionIndicator))
.anchor(0.5f, 0.5f)
.position(
new LatLng(location.getLatitude(), location
.getLongitude())));
This worked for me. This positioned my marker on same location as of google map. (Depends on the accuracy of location though).
Thanks for the answer here

Blue screen in Android Google Maps

I am getting a blue screen when I load my Google Maps on Android. I don't know what I am doing wrong, this is my code for getting the locations:
MapView mapView = (MapView) findViewById(R.id.mapDire);
Route route = directions(new GeoPoint((int)(2*1E6),(int)(34*1E6)),
new GeoPoint((int)(3*1E6),(int)(36*1E6)));
I think can be two things
Your coordinates are 0,0 and the map is opening in the ocean
Something wrong with your API Key
In the first case try zoom out a lot of times and try to see some continent.
In the second try to read the documentation or/and try this link
I hope this helps.
I have this problem in my application and see below code in onlocationchanged method and resolve it.
LatLng myCoordinates = new LatLng(location.getLatitude(), location.getLongitude());
mMap.moveCamera(CameraUpdateFactory.newLatLng(myCoordinates));
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 17.0f));
marker.setPosition(myCoordinates);
Normally blue screen means your Google API key didn't work.
GoogleMaps - Actual Map not showing
If your map is not showing, only grids/blank screen showing, that's because your Map API key is missing or incorrect. Sign up for Google Android Map API.
Try this the link for more info.
There could 3 reasons as to why You see blue screens
Your Long/Lat Points to Water region - or Ocean region, Invariably there's nothing wrong just you Long/Lat Pointing to Water which is blue in color.
Your Long/Lat is wrong and nothing comes up
Your API key is wrong which can be corrected on your Android manifest file
directory: Android/app/src/main/AndroidManifest.xml

Categories

Resources