I am working on an app, in which I would like to display progressbar in InfoWindow of google maps v2. I have managed to customize the InfoWindow using a customized class MapInfoWindowAdapter.
Now, I want to show the progressbar on that InfoWindow as such used in the Uber map, to show progress.
For that, I have tried two things
Using progressbar in info_window_layout file
Using gif image for loader to show the progress, by animating its frames one by one.
Both of them resulted in a static image, i.e, showing no progress at all.
You can't apply animation to the InfoWindow, for one simple reason. what you see in the InfoWindow is not the layout you defined but an image that was drawn from it. meaning you can'y manipulate this InfoWindow.
From Google's 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.
Related
I am using a GoogleMap.InfoWindowAdapter to set the content of my marker's windows.
But the content is on the server and I am using an asynctask to get it.
The deal is that when I have the response my windows has already been created.
And if I wait the asynctask response like this: asynctask.execute(...).get() the application is freezing during the execution.
What I would like to do is to show a window with a progressBar and when I've got the server's response I remove the progressBar and actualise the content of the window.
How could I do that ?
Thanks in advance
so use onPreExecute to start the progressbar and cancel it in onPostExecute
Edit
from the docs:
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 (for example, 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.
what you are trying to do is not going to work since it is rendered as an image. the only way you can simulate this would be to constantly call showInfoWindow() on a progress update
take a look at this link
Google Maps Version 2 - Updating information windows
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.
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);
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.
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.