Info window in an overlay map

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

Info window in an overlay map

Postby j4ck » Mon Apr 28, 2008 8:11 pm

Hi!

I'm trying to put some text in an info window in an overlay above a MapView as the next image show.
I put the text but if the string is too long, this text don't change the line and it's written out of the window.

Somebody knows what can I do? I use this function: canvas.drawRoundRect(); but I can't put a title and a comment as the image, only a short text.

Thanks

Sorry for my bad English

Regard
Attachments
imagen.JPG
imagen.JPG (66.49 KiB) Viewed 743 times
j4ck
Freshman
Freshman
 
Posts: 3
Joined: Mon Apr 28, 2008 7:42 pm

Top

Postby mistapony » Tue Aug 26, 2008 10:34 pm

I am wondering how to do a similiar thing. Can anyone point out the best way to do this?

Thanks.
mistapony
Freshman
Freshman
 
Posts: 2
Joined: Wed Jul 30, 2008 8:15 pm

Postby bavarol » Fri Aug 29, 2008 8:21 pm

Hi,
a question, what do you want to show?
If only text, it should be enough with a showAlert method you could also try with a popup window or dialog if you want to show a picture within.


Like this
Image

I did that with a Dialog, it's an old image(Now I show a half little window and other colors), I wanted to show the info of a saved Point with its coordinates, description and an associated picture.

I hope I could help you ;)
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Postby cassianotartari » Sat Aug 30, 2008 9:17 pm

bavarol wrote:Hi,
a question, what do you want to show?
If only text, it should be enough with a showAlert method you could also try with a popup window or dialog if you want to show a picture within.


Like this
Image

I did that with a Dialog, it's an old image(Now I show a half little window and other colors), I wanted to show the info of a saved Point with its coordinates, description and an associated picture.

I hope I could help you ;)


Can you show how ?
public class pessoa {
private String nome = "Cassiano Tartari";
private String url = "www.cassianotartari.eng.br"
}
User avatar
cassianotartari
Developer
Developer
 
Posts: 28
Joined: Thu Aug 28, 2008 3:42 pm

Postby bavarol » Mon Sep 01, 2008 1:17 pm

Hi

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.          
  2.  
  3. private void showDialog(String description, String picture_path, int latitude, int longitude){
  4.  
  5.        
  6.  
  7.                    
  8.  
  9.                     dia = new Dialog(tourActivity); // <- You can also write this instead of tourActivity
  10.  
  11.                                                                  // That's my MapActivity
  12.  
  13.                    
  14.  
  15.                     View contentView = tourActivity.getViewInflate().inflate(R.layout.info,null,null);
  16.  
  17.                    
  18.  
  19.  
  20.  
  21.                
  22.  
  23.                  
  24.  
  25.                 ImageView pictureView = (ImageView) contentView.findViewById(R.id.picture);
  26.  
  27.                 Bitmap myPic = BitmapFactory.decode(picture_path);
  28.  
  29.                
  30.  
  31.                 // Take care of this code, I develop my programm under m3rc22a cause of prerequisites of my project
  32.  
  33.                 // Some Pictures of my SD Card were sometimes reset, you should control that
  34.  
  35.                 myPic.width();
  36.  
  37.                 myPic.height();
  38.  
  39.  
  40.  
  41.                
  42.  
  43.                    
  44.  
  45.                     TextView descriptionView = (TextView) contentView.findViewById(R.id.descriptionString);
  46.  
  47.                         descriptionView.setText(description);
  48.  
  49.                        
  50.  
  51.  
  52.  
  53.                        
  54.  
  55.                         TextView latitudeView = (TextView) contentView.findViewById(R.id.latitudeString);
  56.  
  57.                         latitudeView.setText((Integer.valueOf(latitude)).toString());
  58.  
  59.                        
  60.  
  61.                        
  62.  
  63.            
  64.  
  65.                         TextView longitudeView = (TextView) contentView.findViewById(R.id.longitudeString);
  66.  
  67.                         longitudeView.setText((Integer.valueOf(latitude)).toString());
  68.  
  69.                                        
  70.  
  71.                                
  72.  
  73.                    
  74.  
  75.                         dia.setContentView(contentView);
  76.  
  77.                     dia.setTitle("Touristic Info");
  78.  
  79.                        
  80.  
  81.                    
  82.  
  83.                     dia.show();
  84.  
  85.    
  86.  
  87.                
  88.  
  89.           }
  90.  
  91.     }
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


And the last and not less important, you should check whether you show such one Dialog, with PopupWindow Object is easy, you have a method called "isShowing()" and you must dismiss this dialog explicit with the method dismiss of Class Dialog and I had to force with an assignment to null the variable "dia" in order to simulate the behaviour of a right PopuWindow.

XML LAyout
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  4.  
  5.    android:orientation="vertical"
  6.  
  7.    android:layout_width="fill_parent"
  8.  
  9.    android:layout_height="fill_parent"
  10.  
  11.    >
  12.  
  13.  
  14.  
  15.     <ImageView id="@+id/picture"      
  16.  
  17.      android:layout_width="wrap_content"
  18.  
  19.      android:layout_height="wrap_content"
  20.  
  21.      android:layout_weight="1" />
  22.  
  23.  
  24.  
  25.    <TextView  id="@+id/descriptionString"
  26.  
  27.      android:layout_width="wrap_content"
  28.  
  29.      android:layout_height="wrap_content"
  30.  
  31.      android:text="Description: "
  32.  
  33.   />
  34.  
  35.    <TextView  id="@+id/latitudeString"
  36.  
  37.      android:layout_width="wrap_content"
  38.  
  39.      android:layout_height="wrap_content"
  40.  
  41.      android:text="Latitude: "
  42.  
  43.   />
  44.  
  45.    <TextView  id="@+id/longitudeString"
  46.  
  47.      android:layout_width="wrap_content"
  48.  
  49.      android:layout_height="wrap_content"
  50.  
  51.      android:text="Longitude: "
  52.  
  53.   />
  54.  
  55.  
  56.  
  57. </LinearLayout>
Parsed in 0.003 seconds, using GeSHi 1.0.8.4



Regards

p.s. I show this Dialog when I run close (i.e. "x" mts) to a Touristic Point (Coordinates+Picture+Description)
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Postby cassianotartari » Tue Sep 02, 2008 5:56 pm

Thank's work fine. But when I try to attach a button(s) doesn't work the listener off the button.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. caixaDialog = new Caixa(mapaActivity);
  2.  
  3.                                 View contentView = mapaActivity.getViewInflate().inflate(R.layout.janela_mapa,null,null);
  4.  
  5.  
  6.  
  7.                                 TextView descricao = (TextView) contentView.findViewById(R.id.descricao_textview);
  8.  
  9.                                 descricao.setText(geoPontoSelelecionado.getDescricao());
  10.  
  11.                                
  12.  
  13.                                 TextView latitude = (TextView) contentView.findViewById(R.id.latitude_textview);
  14.  
  15.                                 latitude.setText(("Latitude: "+Integer.toString(geoPontoSelelecionado.getLatitude())));
  16.  
  17.                                
  18.  
  19.                                 TextView longitude = (TextView) contentView.findViewById(R.id.longitude_textview);
  20.  
  21.                                 longitude.setText(("Longitude: "+Integer.toString(geoPontoSelelecionado.getLongitude())));
  22.  
  23.                                
  24.  
  25.                                 TextView categoria = (TextView) contentView.findViewById(R.id.categoria_textview);
  26.  
  27.                                 categoria.setText(("Categoria: "+geoPontoSelelecionado.getCategoriaDsc()));
  28.  
  29.  
  30.  
  31.                                 Button fecharButton = (Button) contentView.findViewById(R.id.fechar_button);
  32.  
  33.                                 fecharButton.setOnClickListener(new OnClickListener() {
  34.  
  35.                                         @Override
  36.  
  37.                                         public void onClick(View arg0) {
  38.  
  39.                                                 fecharJanela();
  40.  
  41.                                         }
  42.  
  43.                                 });
  44.  
  45.  
  46.  
  47.                                 caixaDialog.setContentView(contentView);
  48.  
  49.                                
  50.  
  51.                                 caixaDialog.setTitle(geoPontoSelelecionado.getTitulo());
  52.  
  53.                                
  54.  
  55.                                 caixaDialog.show();
  56.  
  57.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


My idea is in the future add more buttons to this Dialog.

How I can add the listeners off these buttons?
public class pessoa {
private String nome = "Cassiano Tartari";
private String url = "www.cassianotartari.eng.br"
}
User avatar
cassianotartari
Developer
Developer
 
Posts: 28
Joined: Thu Aug 28, 2008 3:42 pm

Top

Postby bavarol » Thu Sep 04, 2008 12:45 pm

Can you post, your exception protocol?
I could help you so.

Try to debug with Log.i under each of sentence, and check whether a variable is null.

I suppose, your class "Caixa" extends Dialog, I hope it
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Postby cassianotartari » Thu Sep 04, 2008 5:17 pm

I find my stupid error. I think that was because of the many hours programming.

When I extends the Dialog:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.          private class Caixa extends Dialog {
  3.  
  4.                 public Caixa(Context context) {
  5.  
  6.                         super(context);
  7.  
  8.                 }
  9.  
  10.                 @Override
  11.  
  12.                  public boolean dispatchTouchEvent(MotionEvent event) { //<--- here is my Error !
  13.  
  14.                         fecharJanela();//dismiss the dialog and invalidate my overlay
  15.  
  16.                         return false;
  17.  
  18.                        
  19.  
  20.                 }
  21.  
  22.         }
  23.  
  24.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


It is possible to in the method dispatchTouchEvent know if the touch was in out side of the Dialog ? I'd like to close the Dialog when occurs this.

Thanks !
public class pessoa {
private String nome = "Cassiano Tartari";
private String url = "www.cassianotartari.eng.br"
}
User avatar
cassianotartari
Developer
Developer
 
Posts: 28
Joined: Thu Aug 28, 2008 3:42 pm

Postby bavarol » Fri Sep 05, 2008 12:39 pm

cassianotartari wrote:I find my stupid error. I think that was because of the many hours programming.

When I extends the Dialog:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.          private class Caixa extends Dialog {
  2.                 public Caixa(Context context) {
  3.                         super(context);
  4.                 }
  5.                 @Override
  6.                  public boolean dispatchTouchEvent(MotionEvent event) { //<--- here is my Error !
  7.                         fecharJanela();//dismiss the dialog and invalidate my overlay
  8.                         return false;
  9.                        
  10.                 }
  11.         }
  12.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4



It is possible to in the method dispatchTouchEvent know if the touch was in out side of the Dialog ? I'd like to close the Dialog when occurs this.

Thanks !

Hi cassiano,
I suppose "fechar janela" is "close window" , I'm spaniard and "fechar" is an old way to say "cerrar" ;)

Ok, what do you want really? Why do you want to override dispatchTouchEvent? Do you want to close the Dialog if you touch the dialog or only by clicking a button?

As I know, you can use the pen over the screen on a button and it reacts normally but if you desire another behaviour, then you can override that methode of course, then the answer is yes, you can know whether a dialog was "touched" but I don't see the final reason very well but it's your programm ;).

I can't help you anymore, I'm not familiar with the m5 or 0,9 (I develop my app under m3rc22a) apis of Dialog Class, I must see each time I develop something "blank" apis of all of classes in Eclipse, also, by clicking the .jar file and by navigating over directory tree :D

So sad is my story :D

cordiais saudações

Bavarol
bavarol
Experienced Developer
Experienced Developer
 
Posts: 52
Joined: Mon Dec 10, 2007 9:19 pm

Postby cassianotartari » Fri Sep 05, 2008 3:58 pm

As I know, you can use the pen over the screen on a button and it reacts normally but if you desire another behaviour, then you can override that methode of course, then the answer is yes, you can know whether a dialog was "touched" but I don't see the final reason very well but it's your programm Wink.


The idea is accessibility, as well as the close(fecharJanela) button, I would like to click outside the Dialog and close it too.

I'm using M5.

bavarol, is very good to know that I am talking to a person intelligent, which is located across the world :)
public class pessoa {
private String nome = "Cassiano Tartari";
private String url = "www.cassianotartari.eng.br"
}
User avatar
cassianotartari
Developer
Developer
 
Posts: 28
Joined: Thu Aug 28, 2008 3:42 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests