Adding buttons to map infowindow android - android

In the new Google Maps for Android API v2, I can very easily get custom markers and info windows to display. However, I'm trying to have multiple buttons inside of my info window, that each perform a different onClick action but the problem is, the map treats the InfoWindow as it's own button object (no matter where I click on the InfoWindow, it presses the entire thing). Does anyone know how to customize this a bit more?

Just found this in the documentation.
As mentioned in the previous section on info windows, an info window
is not a live View, rather the view is rendered as an image onto the
map. As a result, any listeners you set on the view are disregarded
and you cannot distinguish between click events on various parts of
the view. You are advised not to place interactive components — such
as buttons, checkboxes, or text inputs — within your custom info
window.
Unfortunately, that answers it. I was trying to add the same function as you.

Related

Android Interactive Map With Custom Image

I'm trying to make an android application that has an interactive map.
Then when the app is run and the user selects the map option it will enable location services to show the user where they are on the custom map- and notify them if they are outside of the bounds predetermined.
If they are within the predetermined bounds, I want to show their location on the map while the map is being viewed.
I'd also eventually like to add "areas" to the map that allows a button press or interaction. Example: a "button press" that would allow text to display.
I'm just looking to see if there a either a solution built into to the google map API already, or if there is another open-source solution that has already been made.
For your so called "areas" you can use markers that are clickable and can add listener to them to perform custom click (open new Fragment/Activity or show some info image text etc.). This is good place to start :
https://developers.google.com/maps/documentation/android-api/marker
For predetermined bounds you will need a projection that translate between screen location(coordinates) to geographic coordinates and vice versa.
Nice info for projection can be found here :
https://developers.google.com/android/reference/com/google/android/gms/maps/Projection
You checkout this example on github created by me Link to github

Android : Custom Pin Marker with buttons in Google Map API 2

I am working on android tracking application.
I need to show Connected friends on MapView. Each Friends marker contains image(Person image) and two buttons(Make Call and message) .
Note : The two buttons should show after image pressed.
I try this sample http://www.nasc.fr/android/android-using-layout-as-custom-marker-on-google-map-api/. It shows only TextView.
Is there any way to add custom marker with button or any other ideas to achieve this?
Below image shows the map-view that i want to add live views.
Thanks in Advance
If I'm not wrong, you're looking for infowindowadapter. Did you try infowindowadapter ? If not please implement it .
Here is the link
Visit Here
Thanks. Let me know if it helps.
Finally i ended up with my result with the below link
Google Maps Android API v2 - Interactive InfoWindow (like in original android google maps)
Its quiet interesting to hack layouts.
Thanks,
From the Google Maps V2 documentation:
Note: The info window that is drawn is not a live view. The view is rendered as an image (using View.draw(Canvas)) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (e.g., after an image has loaded), call showInfoWindow(). Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.
Therefore, you can't add buttons to the markers. An idea could be have that buttons somewhere in your layout and show/hide them when the user selects a marker.

How perform click operation on marker custom info window on google map V2 in android

I am implementing google map V2 in my app.I have added custom info window to marker.There are three images cancel,delete & edit.
onclick, cancel image window hide.
delete data delete & on edit dialog open for editing.
My problem is, how perform click operation on on these images?
There is no direct way to do it, but there seems to be workaround for this (which I haven't tested myself yet). You may see a long description in this answer: https://stackoverflow.com/a/15040761/2183804.
https://developers.google.com/maps/documentation/android/marker
Quoting form the docs
Info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described below.
Info window is not a live View, rather the view is rendered as an image onto the map. As a result, any listeners you set on the view are disregarded and you cannot distinguish between click events on various parts of the view. You are advised not to place interactive components — such as buttons, checkboxes, or text inputs — within your custom info window.
You can use an OnInfoWindowClickListener to listen to click events on an info window. To set this listener on the map, call GoogleMap.setOnInfoWindowClickListener(OnInfoWindowClickListener). When a user clicks on an info window, onInfoWindowClick(Marker) will be called and the info window will be highlighted in the default highlight color (Holo Blue for devices running Ice Cream Sandwich and newer, orange for earlier versions of Android).
https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap.OnInfoWindowClickListener
Even though this is an old question I still think people are interested in having info windows with buttons, list etc.
You can check the following library - https://github.com/Appolica/InteractiveInfoWindowAndroid
You can basically add your own fragment as an info window using the manager provided by this library. The following is a snippet of how easily the library can be used. Check the link above for more information
final MapInfoWindowFragment mapInfoWindowFragment =
(MapInfoWindowFragment) getSupportFragmentManager().findFragmentById(R.id.infoWindowMap);
final InfoWindow infoWindow = new InfoWindow(marker, markerSpec, fragment);
// Shows the InfoWindow or hides it if it is already opened.
mapInfoWindowFragment.infoWindowManager().toggle(infoWindow, true);

Android Google maps APIv2 InfoWindow and Markers

I'm using Google maps APIv2 for android. I've implemented MapFragment, put markers where I need, added custom InfoWindow for markers.
The issue is - I have AsyncImages in my InfoWindow and have ProgressBar there. The thing is - ProgressBar doesn't spin, and Image doesn't set after I got it from cache. AsyncImages does work well. I've tested it into another class.
I've replace my AsyncImages view with just single ProgressBar - the same. It doesn't spin.
Any suggestions?
UPD.
Spinner doen't spin cause of
Note: The info window that is drawn is not a live view. The view is
rendered as an image (using View.draw(Canvas)) at the time it is
returned. This means that any subsequent changes to the view will not
be reflected by the info window on the map. To update the info window
later (e.g., after an image has loaded), call showInfoWindow().
Furthermore, the info window will not respect any of the interactivity
typical for a normal view such as touch or gesture events. However you
can listen to a generic click event on the whole info window as
described in the section below.
So the question is - how to realize AsyncImages from web/cache on Maps in the best way?
Create Views array somewhere apart of getContentInfo() method and also create listener smth like OnImageDownloaded?
As stated at Google Maps Android API v2 Documentation:
Note: The info window that is drawn is not a live view. The view is
rendered as an image (using View.draw(Canvas)) at the time it is
returned. This means that any subsequent changes to the view will not
be reflected by the info window on the map. To update the info window
later (e.g., after an image has loaded), call showInfoWindow().
Furthermore, the info window will not respect any of the interactivity
typical for a normal view such as touch or gesture events. However you
can listen to a generic click event on the whole info window as
described in the section below.
Perhaps you should try to call showInfoWindow() somewhere again in your code.
I had the same problem here.
I think that calling showInfoWindows() for a spinning ( indeterminate ) progress bar doesn't make sense to me, and I'm also not sure it works. ( of course showinfoWindows may have sense for a horizontal progress bar)
So I went for one of the following three solutions,
1) left the progress bar not animated beside a "Loading..." text, it gives an idea to the user at least.
2) put the loading spinning wheel somewhere else in the UI.
3) Using a dialog fragment to show loading procedure but it really depends on the feel you want to achieve with your app.
Personally I've chosen the first one.
I really hope that Google will fix this in future.

Android Map Marker-New Screen

I’m new to development, specifically Android. Through tutorials, I’ve managed to display a map with a marker for a building that displays a “toast” box with text identifying that building, when tapped (I fashioned it after the “Noo Yawk” example). I need to display a new full screen with a photo of that building and text describing it, and use the back button to return to the map. I need to do this for at least 30 buildings.
Do I need to start a new activity for each building? It would seem complicated and resource intensive. If so, where will the photo and text reside? Do I need to have a button in the layout to call the map again? Or is there a simpler way to do this? Given the number of buildings, will content management or a database be required?
Thanks in advance and forgive my ignorance. I’ve parsed so many articles and tutorials that I’m becoming confused.
I would just show Dialog with ImageView (photo), TextView (information) and Button (to close Dialog).
Android dialog Screen Example
I think it would be better to keep photo and info inside database and pass them into Dialog before show.
You can display any view on top of the view. Add marker to your map and listen for onClick events on your marker. (see https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/GoogleMap.OnMarkerClickListener)
Within the onClick event you show a view on top of the map.
Do not try to use the InfoWindows of the Maps API as the InfoWindows are rendered as an image and not as a live view. Therefor async loading of your images is not possible with InfoWindows.

Categories

Resources