How can show markers on specific zoom level using Google Maps Android API v2? I have more than 1000 Markers, so it's not good idea to show all on start.
Here is simple example:
#
// latitude and longitude
double latitude = 40.738933;
double longitude = -74.001366;
// create marker
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps ");
// adding marker
googleMap.addMarker(marker);
#
Thank you for help
put below code
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
here Move the camera instantly to marker with a zoom of 15. if you wanna change zoom level you can change.
Related
I am writing an app using Google Maps Android v2 SDK. When I place a marker on the map at my location, it always appears underneath the default "blue dot" from the built-in my location layer. This does not happen when using the Google Maps SDK for iOS. How can I make my own marker be drawn on top of the blue dot?
You can add marker on your location like this :
LatLng latLng = new LatLng(mCurrentLocation.getLatitude(),
mCurrentLocation.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("You");
mCurrLocationMarker = mGoogleMap.addMarker(markerOptions);
mCurrLocationMarker.setVisible(true);
Please search google or stackoverflow first always..Hope it helps
markers have a zIndex() value which you can use
I have implemented google map into my app. I have added a custom marker at my current location.I want to move the marker as the user moves, along with the map. I want to implement the functionality as in google maps navigation. While googling i found the following links but did not get the result. so can any one help me out ?
I have added this in onLocationChanged()
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
sourceLocation = latLng;
startPoint = new GeoPoint(latLng.latitude,latLng.longitude);
forNavigation = location;
// animation
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
// Zoom in the Google Map
mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
// mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mPositionMarker.getPosition(), 15));
mMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(location
.getLatitude(), location.getLongitude())));
These are the links which i found
Google map: moving marker and map together smoothly along with user?
How to smoothly keep moving current location marker in Google Maps v2 android
here is two solution you have.
Use onlocationtrue then it show you blue dot as your current location.
Use fused api for current location and create you marker in locationchanged.
for fused api you can check from here.
thanks
I am building an app in which there is an activity to search games and players and when this activity starts a map also starts.My problem is that the map does not shows current position unless and untill we click on the show my location button..What I want to do is that on start of activity my map will point to my current position as in Google Maps on our android devices along with a pointer or marker ?
Tried this?
LatLng latLng = new LatLng(curlat, curlong); // LatLng current location
gMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
gMap.animateCamera(CameraUpdateFactory.zoomTo(20));
gMap.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("My location"));
I am making an application where I get an message with latitude and longitude, I search that and then plot it on google maps.
How to accomplish the plotting ??
If by "plotting on the map" you mean adding a marker (icon) to a map at a given Latitude / Longitude, you can use the following code to put a Marker on Sydney on the map :
private GoogleMap mMap;
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.addMarker(new MarkerOptions()
.position(new LatLng(-33.88,151.21))
.title("Hello world"));
The LatLng object accepts 2 doubles representing a latitude and a longitude in degrees.
The Google Maps Android API v2 is pretty well-documented. There's also a guide on Markers in Google Maps Android API v2
I'm using Google Maps Android API v2 and I've got everything set up correctly. I have set some markers based on latitude / longitude.
How can I add the Street View image of the lat/lng as an icon?
/* Google Maps API v2 map set code here */
Marker marker = map.addMarker(new MarkerOptions().position(point)
.title("Title")
.snippet("Snippet")
.icon( StreetViewObject? ));
Thanks
You can use this api to get an image based on your latitude and longitude:
https://developers.google.com/maps/documentation/streetview/