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
Related
I have been working on retrieving GPS locations using Google's FusedLocationProvider API for about a week now. I have successfully gotten close to retrieving accurate gps data.
Currently the marker jumps around the map, instead I want it to smoothly animate like Google Maps, Waze, etc. I have searched the entire internet looking for a solution and have not found anything.
You could use animateCamera() method to set focus to new latlng.
CameraPosition cameraPosition = new CameraPosition.Builder().target(
new LatLng(17.385044, 78.486671)).zoom(12).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
This will result in smooth transition.
PS:Play with the zoom to make it more realistic.
You are looking for this
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
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.
All the basic stuff, I have a SupportMapFragment, everything works fine, I just need to know if there is a short way of making the map follow my position or do I have to move the camera every time the location changes?
Well first of all thanks for your time Naskov but this is not a mapView, it's a MapFragment. the code I am using right now (in case someone needs it) is this (onUpdateLocation)
if (mapFragment.theMap != null) {
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(getLocation().getLatitude(),
getLocation().getLongitude())).zoom(14.0f).build();
CameraUpdate cameraUpdate = CameraUpdateFactory
.newCameraPosition(cameraPosition);
mapFragment.theMap.moveCamera(cameraUpdate);
}
I was just wondering if there is some built in method for doing it, also because this doesnt go very smooth. If someone comes up with a better idea please post it
It's not exactly what you want, but you can use:
map.setMyLocationEnabled(true);
To add a button to your map at top right corner (Like in the native Google Maps application) that will allow the user change the camera position to his location when he wants.
I have try the google map v2 example, the "Camera". I know the code below set the tilt to 50 to enable the 3D tilt feature.
static final CameraPosition BONDI =
new CameraPosition.Builder().target(new LatLng(-33.891614, 151.276417))
.zoom(15.5f)
.bearing(300)
.**tilt(50)**
.build();
But after clicking the google map compass, the "tilt" seems to be set to zero, now the 3D feature disappeared and just like a original 2d map.
My problem is how to reset the "tilt" back. I know one way to do that is using "moveCamera()" and give it a CameraUpdate with a "tilt". But is there any other way ?
Thanks.
Drag two fingers down just as in the Google maps app.