I would like create effect described in the title on my markers when they are added. I see for ios exists method marker.appearAnimation but nothing similar for android. Now I will just add a BitmapDescription to MarkerOptions
final Marker marker = mMap.addMarker(new MarkerOptions()
.position(pos)
.icon(getIconForCluster(new BitmapDescriptor(getObjectWrapped()))
);
any suggestions?
You can use the animateCamera() method from GoogleMaps object.
Example:
mGoogleMap.setOnMapLoadedCallback(()
-> mGoogleMap.animateCamera(CameraUpdateFactory
.newLatLngZoom(mMapBoundary.getCenter(), 17)));
with mMapBoundary is a LatLngBounds object. you can set the markers position here, and 17 is the zoom level.
Related
I've been trying to work out a method for my application to indicate when there are markers on the map that are outside of the current view/screen/bound/VisibleRegion.
For example, if there are current 5 markers on the map but the user is zoomed into a part of the map where they can't see any of the markers then I would like to be able to flag up to the user that there are markers on the map that they cannot see or something along those lines (it would be nice to be able to indicate in which direction the markers are from the current position).
I thought of using
LatLngBounds currentScreen = googleMap.getProjection()
.getVisibleRegion().latLngBounds;
but this would only be able to tell me which markers are in the current visibleRegion.
any help would be appriciated, thanks.
First, you should save all your markers somewhere. For example, in list
List<Marker> markers = new ArrayList<>();
Marker marker = mMap.addMarker(new MarkerOptions().position(new LatLng(55.123, 36.456)));
markers.add(marker);
After this you can check, are there markers outside your screen
LatLngBounds currentScreen = mMap.getProjection().getVisibleRegion().latLngBounds;
for(Marker marker : markers) {
if(currentScreen.contains(marker.getPosition())) {
// marker inside visible region
} else {
// marker outside visible region
}
}
i am working on a project, where i have to add a marker using overlay to existing Google map.
i have multiple markers along with infoWindowAdapter,for these i must pass title and snippet. I need one more marker to show only title(i can't directly add a marker with only title,since i used infoWindow for markers it will asks for snippet and ended up with null pointer exception)
I tried this
LatLng currenLoc = new LatLng(location.getLatitude(), location.getLongitude());
Toast.makeText(getApplicationContext(), ""+currenLoc, Toast.LENGTH_SHORT).show();
GroundOverlayOptions curLoc = new GroundOverlayOptions().image(BitmapDescriptorFactory.fromResource(R.drawable.mrk1)).position(currenLoc, 350f, 350f);
gMap.addGroundOverlay(curLoc);
but it shows only a marker like picture not an exact marker. So how to add a marker using ground overlay.?
Hi I have created a map as well as some markers which indicate places/locations on the map. Is there any possible way of creating an animation between those location? For instance drawing a polyline between 2 different locations and create an animation from a start point to an end point ? Is there any documentation for such a thing or any tutorials ? Many thanks.
Something like this:
https://www.youtube.com/watch?v=HPWYorS68WE
use this code and you can also follow this link
https://developers.google.com/maps/documentation/android/
Flat Markers
LatLng mapCenter = new LatLng(41.889, -87.622);
map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 13));
// Flat markers will rotate when the map is rotated,
// and change perspective when the map is tilted.
map.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.direction_arrow))
.position(mapCenter)
.flat(true)
.rotation(245));
CameraPosition cameraPosition = CameraPosition.builder()
.target(mapCenter)
.zoom(13)
.bearing(90)
.build();
// Animate the change in camera view over 2 seconds
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),
2000, null);
}
I am using Google map V2 to put several markers on map. i am using default marker with different color, my problem is that when i perform zoom in or out operation marker changes its position.
I have searched a lot but didn't get any solution.
to add marker i am using following code
myMap.addMarker(new MarkerOptions().position(new LatLng(serverResponse.get(i).getLat(), serverResponse.get(i).getLon())).title(data).snippet(data2));
You have forgotten to call to the method
.anchor(float a, float b)
when you are adding your maker.
Please try this:
myMap.addMarker(new MarkerOptions().position(new LatLng(serverResponse.get(i).getLat(), serverResponse.get(i).getLon())).title(data).anchor(0.5f, 0.5f).snippet(data2));
In my code i am using this sort of code to make a marker option when clicking in a marker .
MarkerOptions op = new MarkerOptions();
op.position(point)
.title(Location_ArrayList.get(j).getCity_name())
.snippet(Location_ArrayList.get(j).getVenue_name())
.draggable(true);
icon = BitmapDescriptorFactory
.fromResource(R.drawable.pin);
I want to change background color of the marker option and make it to black . How to change it programmatically here.
try this..
Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
Use the Icon Factory, as shown here. Just add this to your MarkerOptions.
MarkerOptions op = new MarkerOptions();
op.position(point)
.title(Location_ArrayList.get(j).getCity_name())
.snippet(Location_ArrayList.get(j).getVenue_name())
.draggable(true)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
Make sure that you then create the Marker with the options:
Marker marker=new Marker(op);
its long overdue but may help someone else looking for this ...
You cannot just change the color, what you need to do is use the GoogleMap.InfoWindowAdapter to show the text instead of the more simple title and snippet approach.
You need to override the adapter and set it in your map.
myMapObject.setInfoWindowAdapter(new MyMarkerInfoWindowAdapter());
see in here:
http://www.rogcg.com/blog/2014/04/20/android-working-with-google-maps-v2-and-custom-markers