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.
Related
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!
Very simple question : since MapView inherits from View, is it possible to override draw() to draw whatever you want on the map ?
No, but you can use polylines, polygons, circles. If that's not enough you can put any bitmap (even one you draw to using Canvas) combined with ground overlay. If that's not enough, you can also use tile overlay to draw on entire map efficiently.
It's all there in the documentation, I encourage you to study.
Drawing directly can be always done on a view that overlaps with map, but it won't scroll with map nicely, so better to use technics above.
Drawing directly on the map is impossible, because it doesn't happen in your process afaik.
basically i am trying to draw the path i.e road path. for that i ususally have more then 50 geopoints to link together to draw a path, but the itemized over is also drawing the image on every point, The image that i passed in the constructor. Due to this apart from looking ugly it also slows down my phone. Ite even became hard to move the map too by touching the screen.
so i dont want to draw any image on any geopoint, is it possible or else i should go for Overlay, and a overlay for every couple of geopoint(two geopoints to draw a line between them). I think that would be a overhead for the mobile to manage too many overlays, i.e for 50 geopoints there would be 25 overlays on the map.
That's just what ItemizedOverlay does. Sounds like you need a regular Overlay. Here's an example.
Is it possible to draw a custom region using the Android Google maps API?
The currently available tiles in google maps are missing some information and I was wondering if it is possible to draw custom shapes on top of the Map using overlays?
Also do overlays occupy an entire layer on top of the existing map, or do they only occupy the region which is encompassed in the draw method?
I want only the custom drawn region(if possible) to be interactive to user touches and hence need only the drawn region to respond in a certain manner to user touches/gestures.
Help appreciated.
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