Add map overlay from drawable that spans entire map - android

I have an Android mapview (using Xamarin) that contains two collections of markers, one for property markers and the other for traffic count markers. I need to add a translucent overlay to the map in between the two collections of markers, so that the traffic count markers are above it and are alpha = 1, and the property markers and map tiles are below it and are alpha = .5.
This doesn't seem like it should be too tricky, but I haven't found any examples online of how to create an overlay of a drawable (a translucent 1x1 pixel png image) and stretch it across the map.
My best guess is that I need to use a tile overlay... I saw that there is a UrlTileProvider but that's for loading a url, not a drawable. Also there is the option of implementing ITileProvider directly, however I couldn't figure out how to do it.
Any help would be appreciated!

Related

Google maps in my android app with GoogleMap.MAP_TYPE_TERRAIN washes out the contour lines and elevations

I'm testing some different map types in my application and I'd really like to leverage the topo map for certain areas and the MAP_TYPE_TERRAIN seems to have this. However, I've noticed than when I zoom in, I can initially see the contour lines and the elevations marked on the topo map, but then Google puts some other tile overlay on top of it that washes out the lines and the elevations. It makes for a neat effect because it gives it a 3D kind of feel, but I'd rather keep the actual topo info for my purposes. Is there a setting or something I can toggle to prevent the API from adding that extra layer? Again, as I said, I can see it there initially as I pan to a new area, or zoom in to a different tile set, it just subsequently gets washed out when Google is done painting the map.
There is no way to configure the default behavior of specific map types (TERRAIN, SATELITE, etc). What you can do is come up with your own custom TileOverlays.
Here's a bit of intro about Tile Overlays.
The simplest and most common way of creating a tile overlay is to
provide a URL pointing to the relevant tile image. UrlTileProvider is
a partial implementation of TileProvider that provides image tiles
based on a URL. This class requires that all the images have the same
dimensions.
You will need to implement UrlTileProvider.getTileUrl(), which accepts
the tile coordinates (x, y, zoom), and returns a URL pointing to the
image to be used for the tile. The method should return null if there
is no tile for the given x, y and zoom. A URL can point to a web
resource, an Android asset, or a file on the local disk.

Android Is it possible to change the appearance of the map in the google maps API

I have been searching in the documentation and throughout google. I would like to know if it is possible to place an image over the map the api comes from to use something else as a visual but with the maps gps functionality. Does anyone know if this is possible?
You can use two types of Overlays:
TileOverlays (reference)
A TileOverlay defines a set of images that are added on top of the base map tiles. You can also use tile overlays to add extra features to the map by providing transparent tile images. You need to provide the tiles for each zoom level that you want to support. If you have enough tiles at multiple zoom levels, you can supplement Google's map data for the entire map.
GroundOverlay (reference)
A ground overlay is an image that is fixed to a map. Unlike markers, ground overlays are oriented against the Earth's surface rather than the screen, so rotating, tilting or zooming the map will change the orientation of the image. Ground overlays are useful when you wish to fix a single image at one area on the map. If you want to add extensive imagery that covers a large portion of the map, you should consider a Tile overlay.

Setting opacity/alpha with shapes/tiles in Google Android v2

I'm working on an app based on Google Maps Android v2. Simply put I want to render some shapes or animations on the map.
Looking over the Android developer spec at https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/package-summary
I see you can add Shapes, Polylines, and tiles. None of them seem to have an opacity or alpha property I can set.
Ideally, I just want to set a circle on a marker (either by using the same LatLng) or as a property of the marker itself (overload Marker?) and have this circle be animated and partially transparent.
Ultimately I'm going to want some control over these objects and how they render. Are tiles more appropriate?
All shapes (Polylines, Polygons and Circles) accept ARGB as their fill and stroke colors. Just use translucent color like 0xAA00FFFF.

Android Overlays for drawing shapes in Google Maps

I want to draw several shapes (over 40) for separated zones in a city and I am not sure what is the best way to do this. I am considering drawing the shapes using:
ItemizedOverlay.
Overlay: One overlay for all shapes.
Overlays: One overlay for each shape.
What do you think?
I haven't been using ItemizedOverlay so can't say anything about it but if you are to choose between Overlay and Overlays - take one Overlay for all items.
One overlay is one canvas and one draw method. One overlay for each object are multiple canvases and drawing methods. This is pointless.
You should use different overlays only when you create "layers" which can be visible or not (as a whole layer) like Google Satelite or Google Street View.

I am trying to develop a map(basically a static image) in ANDROID where I can show different items(drawn in the map itself)

I am trying to develop a map(basically a static image) in ANDROID where I can show different items(drawn in the map itself). How can I do that. I've tried different approaches. The map is basically a static image. Please help!
More details on what you're trying to do would help to answer this question correctly. What methods have you tried already?
Are you trying to just draw static images overlaid each other in a view?
Are you trying to draw an actual geographic map with a MapView or something along those lines?
If you're trying to draw an image over another, you can do it in a number of ways.
You could use a RelativeLayout to assign absolute positions your overlay images (most likely each in the form of an ImageView). Here's a good SO answer that covers assigning absolute positions to children in an RelativeLayout: Set the absolute position of a view
You could load the base image (your map) and the overlays into Bitmap objects. Then, using a Canvas object you could draw them in specified locations. Look at the various Canvas.drawBitmap() functions to see your options on specifying the position of the Bitmap you are drawing. You could also draw shapes instead of images using the drawRect(), drawRoundRect(), drawLine(), or drawOval() methods. There are other options as well. Read the Canvas documentation.
Otherwise, if you're trying to draw a movable map of some sort, then you'll need to use a MapView or MapActivity. There are classes that you use to overlay images in specified locations on the map. This won't be a static image, but a movable map along with the overlays that stay in the specified location. You'll use the ItemizedOverlay class to act as a data structure to store your actual overlay images (wrapped in the OverlayItem class).
This is a great tutorial that goes into depth about what I'm talking about:
http://developer.android.com/guide/tutorials/views/hello-mapview.html

Categories

Resources