1. Check out our companion app, Forums for Android! Download from Google Play

Markers in Google Maps FC's the app on touch

Discussion in 'Application Development' started by joyu12, May 2, 2010.

  1. joyu12

    joyu12 New Member
    Thread Starter
    5

    Feb 13, 2010
    4
    0
    5
    Student
    Oslo, Norway
    I am trying to add infowindows to markers/pushpins on the map. ATM, it is not working. It makes the app force cloce. Here is the code for the tabhost, maps and overlays(i am including the webview aswell, but only because it may be causing the problem)
    Current code(Tabhost, maps:
    TravelBuddy.java/TabHost
    Code (Text):
    1.  
    2.  
    3.     package com.jappapps.android.travelbuddy;
    4.  
    5.     import java.util.List;
    6.  
    7.     import android.app.TabActivity;
    8.     import android.content.Context;
    9.     import android.content.Intent;
    10.     import android.graphics.drawable.Drawable;
    11.     import android.os.Bundle;
    12.     import android.webkit.WebView;
    13.     import android.widget.TabHost;
    14.     import android.widget.TabHost.TabSpec;
    15.  
    16.     import com.google.android.maps.Overlay;
    17.  
    18.     public class TravelBuddy extends TabActivity {
    19.  
    20.     TabHost mTabHost;
    21.  
    22.  
    23.     /** Called when the activity is first created. */
    24.     @Override
    25.     public void onCreate(Bundle savedInstanceState) {
    26.         super.onCreate(savedInstanceState);
    27.         //setContentView(R.layout.main);
    28.  
    29.         Context ctx = this.getApplicationContext();
    30.        
    31.         //tab 1
    32.         mTabHost = getTabHost();
    33.         TabSpec tabSpec1 = mTabHost.newTabSpec("Maps");
    34.         tabSpec1.setIndicator("Map");
    35.         Intent i1 = new Intent(ctx, MapTabView.class);
    36.         tabSpec1.setContent(i1);
    37.         mTabHost.addTab(tabSpec1);
    38.        
    39.         //tab2
    40.         mTabHost = getTabHost();
    41.         TabSpec tabSpec2 = mTabHost.newTabSpec("Web");
    42.         tabSpec2.setIndicator("Featured");
    43.         Intent i2 = new Intent(ctx, WebView1.class);
    44.         tabSpec2.setContent(i2);
    45.         mTabHost.addTab(tabSpec2);
    46.         /*
    47.         List<Overlay> mapOverlays = mapView.getOverlays();
    48.         Drawable drawable =               this.getResources().getDrawable(R.drawable.androidmarker);
    49.         Overlays itemizedoverlay = new Overlays(drawable);*/
    50.     }
    51.        }
    MapTabView.java/Map:
    Code (Text):
    1.  
    2.  
    3.     package com.jappapps.android.travelbuddy;
    4.  
    5.     import java.util.List;
    6.  
    7.     import android.graphics.drawable.Drawable;
    8.     import android.os.Bundle;
    9.  
    10.     import com.google.android.maps.GeoPoint;
    11.     import com.google.android.maps.MapActivity;
    12.     import com.google.android.maps.MapController;
    13.     import com.google.android.maps.MapView;
    14.     import com.google.android.maps.Overlay;
    15.     import com.google.android.maps.OverlayItem;
    16.  
    17.     public class MapTabView extends MapActivity {
    18.    
    19.     MapController mapController;
    20.     @Override
    21.     protected void onCreate(Bundle savedInstanceState) {    
    22.         super.onCreate(savedInstanceState);    
    23.         setContentView(R.layout.maptabview);
    24.        
    25.         MapView mapView = (MapView) findViewById(R.id.mapview);    
    26.         mapView.setBuiltInZoomControls(true);
    27.        
    28.         List<Overlay> mapOverlays = mapView.getOverlays();
    29.         Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
    30.         Overlays1 itemizedoverlay = new Overlays1(drawable);
    31.        
    32.         GeoPoint un = new GeoPoint((int) (59.911868847598406*1E6), (int) (10.73362112045288*1E6));
    33.         OverlayItem overlayitem = new OverlayItem(un, "Oslo R
     

    Advertisement

  2. YoungDroid

    YoungDroid New Member
    25

    Jul 19, 2010
    2
    0
    25

Share This Page

Loading...