Android Map v2 static pin - android

I've created an activity which shows a map v2. I would like to create a fixed pin at the center of the map. If panning around the screen the pin stays fixed at the view's center.
I've only found a tutorial showing how to create markers, but they keep they keep scrolling with the map when panning around. As an example, the UBER app uses this kind of fixed pin:
As you might see, the pin is in the middle of the screen and stays there also when panning around.
Any suggestions how to achieve that?

Related

Setting boundaries for pinch-zoom in Maps view

For an app I'm working on the user needs to be able to zoom in and out using pinch gestures, but only within a certain boundary.
There are multiple "levels" on which users can see the map and there should be a settable zoom boundary for each of these.
We got this working partially by resetting the camera back to the limit if pinching has brought it outside of it's boundaries, but the user shouldn't be able to pinch out/in of the boundaries at all.
Here's a video of how it's working now:
https://www.youtube.com/watch?v=WfAle_M-i0k
And how it should work is that once the camera is at the zoomlevel-limit, zooming out further shouldn't be possible.
This is important because we'll be drawing a lot of objects on the screen and the app crashes when it's zoomed out too far.
We're using the default pinch-zoom that comes with
mMap.getUiSettings().setZoomGesturesEnabled(true);
Is there a way to disable further zooming in/out when the boundary has been reached?
I don't see any other way of doing this that implementing zoom controls by yourself, i.e. setting
mMap.getUiSettings().setZoomGesturesEnabled(false);
and adding buttons on top of your map with actions with zoomBy inside (with respect to your zoom boundaries kept somewhere).
You may also check lite mode.

Drawing on the MapFragment, while keeping some elements visible

I'm developing an application that has the following goal:
Using the google maps android API 2 I get my current position, and as I start walking the application starts drawing the route I take
The twist is that the map is a "blind" map. Meaning the map is hidden, only the Marker of my current position and a dotted line of my route is shown.
Keep in mind I'm a novice developing to Android, so please be specific. (Thank you)
I managed to create the map, get my current position and zoom in to it (Had no sens to see the whole planet while i want only my current position). And it's pretty accurate so far.
The thing is I don't know what should I do from this point on.
Basicly I need a white View between the Marker and the real map. Also as I advance that View should always be on, over the MapFragment/MapView. Also I wish to keep the zoom and drag functionality's of the MapFragment.
How can I achieve this?
At this point I'm opened to any solutions.
(Been browsing for a few days now the developers site, I have seen that with the ViewOverlay class I can put messages over the map, but I'm not sure what would the correct aproach be in my case...)
To hide the whole map behind the white view I would use Polygon class Polygon Even if you specify Polygon to cover the whole map Markers will be still displayed in front of it and as so user's current position marker will be visible. You also will be able to zoom and drag.
To draw line on map use Polyline class Polyline It will draw users path as a polyline. If you want to stick with dotted line you can use Circle objects to create it. Circle

Android Google map with inset overview when zoomed in

I am developing an android application using Google maps with clustering of markers. The application works fine however once you zoom into a specific area and all the clusters expand to individual markers I would like to also show a small view that represents the entire map, where you are, and where all the markers are, to enable the user to navigate round the map while zoomed in. Ive Googled and searched SO, but not found anything. Is there any "off the shelf" solution? Or am I going to have to code this all myself? The type of solution I am looking for is the type of small window that many games use to show an overview of where the player is and all the points of interest are within the current level.
I haven't seen any "off the shelf" solutions, but here is what I would do here:
1) Create an additional fragment of the map. Place it in one of corners like games do
2) Here is where all the magic should happen. You need to synchronize these 2 maps. Map's Projection lets you to translate geo coordinates into XY coordinates within the view. That's being said you can get lat/lng of your top-left and bottom-right corners on the main map and translate these 2 corners into top-left and bottom-right XY coordinates of the mini-map's view. Now, when you have XY coordinates, the only thing you need to do - is to draw a rect on top of the mini map.
There is even easier and more native solution - since you have top-left and bottom-right lat/lng coordinates - you can draw a set of polylines on a minimap to get a rect. But in this case it will be hard to move it around (with your finger) in case you want to change current main map location using mini-map

How to make a Custom marker on google maps disappear if it is not in focus

Some of the markers in google maps appear when zoomed in. However, when a user drag the map into a different place, the marker disappears, and when you drag it again on the previous place, the marker starts to animate in front of you (I hope you are getting what I'm trying to say). I want to know if there is such a way to do that. Thanks.
The same thing happens in Google Maps Android API v2 on street names, parks, etc.
There is no support for marker transparency as of this writing. You will have to code it yourself: posting to Handler until the animation finishes and setting new icon every "frame" with increasing opacity.

How to hide the gray/white areas in mapView in android

In the following screenshot you can see a white area (highlighted by red) appearing by default in every mapview. I know that the mapView in android has this default behavior but when the native Google Maps app is launched in the device, it doesnt show the white area. I would like to see that behavior. But i am out of options. Should there be any scroll listener on the map which will stop the panning over white areas. Any help is appreciable.
Thanks,
In the following screenshot you can see a white area (highlighted by red) appearing by default in every mapview.
It does not appear "by default in every mapview". This sample application, for example, does not have these areas, at least at reasonable zoom levels.
It is likely that your problem is purely at a zoom level of 1, due to the aspect ratio of the Mercator projection. It has been years since I bothered with a zoom level of 1.
but when the native Google Maps app is launched in the device, it doesnt show the white area
That is because the Google Maps application does not start out at a zoom level of 1. If, however, you pinch-to-zoom to get to its lowest zoom level, then pan around, you will see those white spaces above and below the map. Again, this is most likely due to the aspect ratio of the Mercator projection.
Should there be any scroll listener on the map which will stop the panning over white areas.
I doubt it.

Categories

Resources