Google Maps Android -- How access default infowindow? - java

I have a map that shows a few points. If the user searches for a location instead of using their default location, a placemark will show for the searched location as well. This placemark shows the infowindow by default. All of these points are shown on screen (using a bounding box).
However, although I can account for the placemark to be shown on screen inside a bounding box, I am currently unable to make sure its infowindow is completely visible on screen. For example, if the placemark is the northeast-most item, its infowindow will be overflowing off the screen both on the top and the right.
Is there any way to get the infowindow of a marker? I know I can build one out using the CustomWindowAdapter and later access that view, but I don't want to customize it at all, just to be able to access it (and not just be able to call show or hideinfowindow() from the marker).
Ideally, I could get the height and width of the infowindow in pixels and use that to make sure it is always completely shown on screen.

No, you cannot. What you see as "info window" inside the map view is nothing more than a buffered snapshot (or a screen dump if you will) of the view created by your InfoWindowAdapter, meaning it's not a traditional view added to the view hierarchy, rather it's an image shown in the OpenGL context.
Accessing or manipulating this view after showInfoWindow() won't make any difference to what gets displayed on the map, at least until you call showInfoWindow() again to take a new snapshot.
It's the same reason you cannot add a long-click listener to the info window.

Related

How to set negative translationX before app load

when I set a view's translationX whether via XML or programmatically android seems to ignore the code.
When I run view.setTranslationX(-200); it ignores the translation and the app shows the view at 200 instead
If I run via post Runnable or overriding onMeasure it can be moved to -200 but it momentarily shows when the app loads. I don't want it to be seen on app start
What can I do to translate view before widget is shown.
When is the earliest I can set translationX?
The view/layout is not inflated yet so you can't.
Do you mind if I ask why you want to do it before the widget is shown?

Android Multiple Grid Image

I want to do following things:
1-Create a grid(Size is depend on number of image series) of images on one screen
2-When clicked/chosen a image.
3-second grid (Size is depend on number of image series) of images will be on screen.
4-Horizontal Swipe the first screen to next one to display the other grid(i.e remaining images)
5-When clicked/chosen a image on last grid, an image or layout will be on screen.
Similar to the Grid we see in our android Phone's
Any answer truly Appreciated...
Assuming I understand this correctly, you are probably thinking of a GridView, which takes an adapter to populate the grid with images, just like an adapter for a ListView populates the list with Textviews (or whatever you have in your custom adapter layout).
As for the support to select an image to go to another grid (subdirectories of images?) and swiping between various grids, this would be done using Fragments. For the subdirectory stuff, I don't know if there is an API somewhere to help with this, but if not you would need to implement a recursive tree structure: the internal nodes would define a point that can be selected to navigate to the next level, and the external nodes would be the individual images. Selecting an internal node would enter that subdirectory, and selecting an external node would open a second Fragment with the larger view of the image.
This is all a bit vague, but hopefully it gives you a place to start looking around. Read the developer docs on GridViews and Fragments to see if they help at all.

Android Setting Up Splash Screen(Activity) Like Iphone Part2

After getting solution to call my splash activity only one time (Part1 Question), Now i have to set up my splash activity.
On My First Layout i want functionality like this :
Image One <--> Image Two <--> Imgage Three --> Second xml(Activity)
Also on every image their will be a page control that will indicate on which image is currently on layout(Like the attached screenshot)/ or can be any other way to show this.
That Means From Image one i can go to image two on scrolling to right(I can come back to image one on scrolling to left) From Image two i can go to Image Three on scrolling right(I can come back to image 2 from Image three if i scroll to left)But if i scroll to right from Third Image then i should get to my Second Activity and never return back on those images.
i.e
I want to have scroll view having those three images with the page controller then after we scroll down to the third/last image on further scrolling to right i want that my second activity should be loaded and the splash should never come up.
Can any one tell me any idea how this can be done.
To make splash sheet with scroll view and page control & switch to second activity when done scrolling.
I don't want animation i want it to work manually like scrolling/ or any other way to implement this.
Coding will be much appreciated.
To implement scrollable images like shown above use ViewPagerIndicator library given HERE. Its simple to integrate and will take few minutes. All you have to do is read the usage section in given link.
For switching activity on last page, simply implement onPageChangeListener described in link and check for page number.

Android - How to display another overlay in onTap action of another overlay

I am using MapView to display some polygons (zones) as Overlays on the canvas. I extended the class Overlay and now would like to implement the onTap method. After user taps on one of these zones another overlay should be displayed. I would like to define the layout of this overlay as a normal XML layout and than just inflate it and display.
I have already looked on one example called android-mapviewballoons, but it uses itemized overlays which take an Drawable resource and display it on the mapview. This drawable can than be taped. In my case I want my zone (polygon) to be the clickable resource. Can anyone help me please?
Step #1: Implement onTap() in your Overlay and confirm you are getting control when you want to.
Step #2: Adjust your existing layout such that the MapView is in a container that supports Z-axis ordering, like a RelativeLayout
Step #3: In onTap(), add another child to the container (and, eventually, get rid of that child, when appropriate)
Here is a sample app from one of my books demonstrating this with an ItemizedOverlay, but there should be no significant difference for using the technique with a regular Overlay.

Help with code layout

I hope I can explain this properly.
I'm making an android app that, when you open it, it connects to a JSON server, pulls down the data (GPS coords) and dynamically creates a "menu" based on what it received (View1). This will consist of a few buttons, which when clicked, will load a MapView (View2) with the coords gotten from the JSON represented as markers on the map.
I start off with setContentView(R.layout.menu) then get the data, onbuttonClick I load setContentView(R.layout.map) and draw the markers. The problem is, I have an onLocationChangedListener that goes through the code to set up the menu initially. When it tries to build the menu when the mapView is open, I get a force close. Unfortunately, this code also updates the user location and the locations of the overlays and re-draws the map.
My question is: Can I do a check on a layout to say something like if (isActive) so that I can perform actions only if the current view is in focus?
OR should I scrap the whole thing and start again with a better layout? (Suggestions welcome)
Summary::: I have 2 views (menu,map). Need access to same data across both. Currently works with setContentView() but gives me a Force Close when actions are performed on inactive view.
If I understand correctly, you are using setContentView(someLayoutId) to change each time what the Activity is displaying. This is not the way android apps usually work. When you retrieve a resource, you need a root element to reference it, that's why you get the exceptions when the View is not "active".
You have several other options to evaluate:
Create a new MapActivity to show the map
Create a TabActivity and add the map as a new tab
Use a ViewSwitcher to decide whether to show the map or not.

Categories

Resources