How to place an image(+sign) at the center of map?

Put your problem here if it does not fit any of the other categories.

How to place an image(+sign) at the center of map?

Postby Jitendra Kumar » Thu Mar 06, 2008 12:59 pm

Hi Guys. I m having a prblm with my application, i want a +sign at d center of map that represents d user and can b viewed with d map.
Jitendra Kumar
Developer
Developer
 
Posts: 49
Joined: Thu Mar 06, 2008 7:55 am
Location: Bangalore

Top

Postby plusminus » Fri Mar 07, 2008 12:29 am

Hello Jitendra Kumar,

what about using less abbrevs. ;)

You can easily do this by using a RelativeLayout, like this :darrow: (it centers an image in the bottom over the mapview).
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.         android:layout_width="fill_parent"
  4.         android:layout_height="fill_parent">
  5.         <view class="com.google.android.maps.MapView"
  6.                 android:id="@+id/map_map"
  7.                 android:layout_width="fill_parent"
  8.                 android:layout_height="fill_parent"/>
  9.         <ImageView
  10.                 android:id="@+id/iv_map_logo_googlemaps"
  11.                 android:layout_alignParentBottom="true"
  12.                 android:layout_width="fill_parent"
  13.                 android:layout_height="wrap_content"
  14.                 android:scaleType="fitCenter"
  15.                 android:gravity="center_horizontal"
  16.                 android:src="@drawable/logo_googlemaps"
  17.                 android:padding="5px"/>
  18. </RelativeLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby plusminus » Fri Mar 07, 2008 12:31 am

Just realized you want to display the user-position, like this:

Image


:arrow: have a look here: viewtopic.php?t=92

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Jitendra Kumar » Fri Mar 07, 2008 6:03 am

Hi! This is Jitendra, Wat i want in my application is dat user is always at d center n whether map moves or not the image sud not move.It sud always be at d center. Hope u got wat i want
Jitendra Kumar
Developer
Developer
 
Posts: 49
Joined: Thu Mar 06, 2008 7:55 am
Location: Bangalore

Postby plusminus » Fri Mar 07, 2008 2:34 pm

Hello Jitendra,

you want the icon represent the GPS-location of the device, or just a dumb icon in the middle :?:

Regards,
plusminus

PS: Please use no more abbreviations, because others maybe won't find your problems via search!
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Jitendra Kumar » Mon Mar 10, 2008 5:41 am

Its just a dumb icon at the center that should be visible with the map .
Jitendra Kumar
Developer
Developer
 
Posts: 49
Joined: Thu Mar 06, 2008 7:55 am
Location: Bangalore

Top

Postby plusminus » Mon Mar 10, 2008 3:06 pm

Hello Jutendra,

I am assuming you don't need it clickable. Like a crosshair :?:
So try this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.myMapView.createOverlayController().add(new MyOverlay(this), true);
Parsed in 0.029 seconds, using GeSHi 1.0.8.4

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         class MyOverlay extends Overlay{
  2.  
  3.                 Bitmap crossHair;
  4.  
  5.                 Paint p;
  6.  
  7.                
  8.  
  9.                 MyOverlay(Context ctx){
  10.  
  11.                         this.crossHair = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.crosshair);
  12.  
  13.                         this.p = new Paint();
  14.  
  15.                 }
  16.  
  17.                
  18.  
  19.                 public void draw(Canvas canvas, PixelCalculator pxC, boolean b) {
  20.  
  21.                         int centerX = canvas.getBitmapWidth() / 2; // Not 100% sure if correct values are returned
  22.  
  23.                         int centerY = canvas.getBitmapHeight() / 2;
  24.  
  25.                         canvas.drawBitmap(this.crossHair,
  26.  
  27.                                         centerX - (this.crossHair.width() / 2),
  28.  
  29.                                         centerY - (this.crossHair.height() / 2),
  30.  
  31.                                         this.p);
  32.  
  33.                 }
  34.  
  35.         }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Jitendra Kumar » Tue Mar 11, 2008 6:23 am

Hi Plus Minus . Many many thanx to U. I was confused whether to draw a canvas or to create an overlay . Thnax a lot :D :D
Jitendra Kumar
Developer
Developer
 
Posts: 49
Joined: Thu Mar 06, 2008 7:55 am
Location: Bangalore

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 13 guests