Google Maps v2: launch custom infowindow without using a marker - java

My question is regarding the java way of achieving this: Google Maps infoWindow without marker?
Is it possible to launch a custom info window in v2 without using a marker? Which event should I use to detect a long press on the map and how can I launch an InfoWindow?
Here is what I want to achieve.
I need to be able to get the location from the place, so I can add the marker to that position, whenever an icon from the custom view is selected.

Is it possible to launch a custom info window in v2 without using a
marker?
It isn't, but you can create a transparent marker and show the InfoWindow on it.
To make it transparent, use a transparent resource or use marker.setAlpha(0.0f).
Which event should I use to detect a long press on the map?
You can use the method GoogleMap.setOnMapLongClickListener().
How can I launch an InfoWindow?
You have to add a Marker and call showInfoWindow() method on it.

Related

Close Google Map InfoWindows from fragement

I am trying to figure out a way to close an open Google Map Marker InfoWindow from another visible fragment by clicking on a button.
An InfoWindow can be closed by simply call marker.HideInfoWinow()
But this assumes you have access to the marker, which I do not have from within the Fragment.
I also read that only one InfoWindow can be open at a time so I was hoping that the map had a method to determine which marker's infowindow was open.
I know to use callback interface to communicate between the map fragment, the activity, and the other fragment.

Add buttons on google map

I need to add some stylish button on Google map in my application just the placed in image.
Kindly help me to add.Thanks in Advance.
Here is the demo that i want to create
You need to create a view that decorates/wraps your Google Map View. You can then configure this view how you would like with buttons, overlays, etc and use click listeners to delegate to the map events you would like performed.

Google Maps Android -- How access default infowindow?

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.

Google Map View on Non Touch-Screen Phones

I have implemented Google Map view in my app with a number of custom markers. I am testing in the emulator and everything works fine if I treat the emulator like a touch screen phone - I can click on the custom markers and navigate and move the map properly.
However I don't seem to be able to manipulate the map with the trackball / dpad controls. Can Google Map view be used with the trackball or dpad ?
Thanks !
Try overriding the onTrackballEvent(android.view.MotionEvent event) method in the MapView.

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