开发者

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 s开发者_Python百科tatic 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?

  1. Are you trying to just draw static images overlaid each other in a view?
  2. 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜