I'm creating an application with new Google Maps API V2 and I have to intercept the click on InfoWindow, showed when a Marker is clicked.
Reading the documentation I assumed that I do that to listen to InfoWindows clicks :
mGoogleMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
#Override
public void onInfoWindowClick(Marker marker) {
Log.d("", marker.getTitle());
}
});
But unfortunatly the method is never called.
If I try to listen to marker click and use setOnMarkerClickListener instead of OnInfoWindowClickListener , this works fine.
Hope to find some help, thanks in advance
The OnInfoWindowClickListener gets called when you actually click on the Marker title popup and not the marker.
The above just works fine.
Related
What I want ?
When user taps on marker its image should change and user should be able to move the marker and I should be able to get the latitude and longitude . Below is a video of requirement .
What I have tried so far ?
I tried to implement default marker drag listener but it only works with long press .
I looked on similar questions on stack overflow but no luck .
Tried with ground overlay but not had much luck .
So how can I achieve this behaviour , Any hint is appreciated . There is already an app out there which does it so this should be possible .
As per documentation you are required to use:
GoogleMap.OnMarkerClickListener
public static interface GoogleMap.OnMarkerClickListener
Which Defines signatures for methods that are called when a marker is clicked or tapped.
With public method:
abstract boolean onMarkerClick(Marker marker)
Called when a marker has been clicked or tapped.
INSTEAD OF
GoogleMap.OnMapLongClickListener
public static interface GoogleMap.OnMapLongClickListener
with Public method:
public abstract void onMapLongClick (LatLng point)
Called when the user makes a long-press gesture on the map, but only if none of the overlays of the map handled the gesture. Implementations of this method are always invoked on the Android UI thread.
I have opened "Google Map" Application from my App.
What I want is I want to add my app button for navigating to my app, over only google map not on other apps.
Using this link ,I have added overlayservice to my app but it will overdraw over every other application on device window.
I only want to draw over google map app Like this.
This started off as a comment, and then morphed into something of an answer. One option would be to draw a custom marker on your Google Map for the taxi icon. Whenever there is a zoom, drag, etc., you might have to do a re-render to get it in the same place again. I can verify that it is possible to capture click events on a custom marker in Android. Here is what your setup might look like:
#Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setOnMarkerClickListener(this);
mMap.setOnCameraMoveListener(this);
// ...
}
Then, override the marker click listener:
#Override
public void onCameraMove() {
// remove the old marker, and redraw it again on the left of the screen
}
You also probably would want to capture click events on your custom marker:
#Override
public boolean onMarkerClick(final Marker marker) {
// ...
}
The above onMarkerClick() method receives a reference to the marker which was clicked. You may keep an activity-scoped marker, and then check if it matches what was clicked to decide whether or not your custom marker were clicked.
I have a map with markers that sit pretty close to each other sometimes. When tapping one the click event also occurs on the markers that sit behind the one that was clicked. The listener is implemented as follows.:
googleMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
#Override
public boolean onMarkerClick(Marker marker) {
presenter.onMarkerClicked(activeMarkers.get(marker.getId())
.getModelId());
return true;
}
});
Is there a way to avoid this without introducing extra state to my fragment?
you'll have to make tags for your markers so you can identify them... each marker has a setTag ..utilize that so you can differentiate them in the listener.
My app uses a GoogleMap. One of my testers reports that on his new Galaxy Tab 4 running Android 5.0.2, the map has a button on it which launches Google navigation. I did not put that button there, and I don't see it on any of my devices.
How do I get rid of that button?
map.getUiSettings().setMapToolbarEnabled(false);
I got more details from the tester. The button only appears when a marker is clicked. I disabled it by setting a marker click listener that consumes the event and does nothing:
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
#Override
public boolean onMarkerClick(final Marker marker) {
return true;
}
});
I have an map fragment in my android application. What I want to do is make it clickable so that if someone clicks anywhere on the fragment I can start a new activity. I tried doing some research but all I'm coming up with is how to make map markers clickable or not clickable. My map fragment only takes up a small portion of my activity and shows only one map marker.
Try this:
map.setOnMapClickListener(new OnMapClickListener() {
#Override
public void onMapClick(LatLng point) {
startActivity(new Intent(yourActivity, nextActivity.class));
}
});
i think you do it implementing on touch listener on map fragment view it will work for me, if click on map fragment u can open map full view in another activity.
may be this will be help u