@Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_I) {
      // Zoom not closer than possible
      this.ushMapController.zoomIn();
      // this.myMapController.zoomInFixing(Math.min(21, this.myMapView.getZoomLevel() + 1));
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_O) {
      // Zoom not farer than possible
      this.ushMapController.zoomOut();
      // this.myMapController.zoomInFixing(Math.max(1, this.myMapView.getZoomLevel() - 1),0);
      return true;
    } else if (keyCode == KeyEvent.KEYCODE_T) {
      // Switch to satellite view
      mapView.setSatellite(true);

      return true;
    } else if (keyCode == KeyEvent.KEYCODE_M) {
      // Switch to satellite view
      mapView.setSatellite(false);

      return true;
    }

    return false;
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   // Handles the menu item selection.
   switch (item.getItemId()) {
     case R.id.menu_satellite:
       mMapView.setSatellite(true);
       mMapView.setTraffic(false);
       return true;
     case R.id.menu_map:
       mMapView.setSatellite(false);
       return true;
     case R.id.menu_traffic:
       if (mMapView.isTraffic()) {
         mMapView.setTraffic(false);
       } else {
         mMapView.setTraffic(true);
         mMapView.setSatellite(false);
       }
       return true;
     case R.id.menu_help:
       showHelpDialog();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
示例#3
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    switch (item.getItemId()) {
      case R.id.Sat_View:
        mapView.setSatellite(true);
        mapView.setStreetView(true);
        return true;

      case R.id.Map_View:
        mapView.setSatellite(false);
        mapView.setStreetView(false);
        return true;

      case R.id.Map_Menu_All:
        startActivity(new Intent(this, Maps.class));
        Toast.makeText(this, R.string.toast_all, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Free:
        startActivity(new Intent(this, MapsFree.class));
        Toast.makeText(this, R.string.toast_free, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Art:
        startActivity(new Intent(this, MapsArt.class));
        Toast.makeText(this, R.string.toast_art, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Mansion:
        startActivity(new Intent(this, MapsMansion.class));
        Toast.makeText(this, R.string.toast_mansion, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_History:
        startActivity(new Intent(this, MapsHistory.class));
        Toast.makeText(this, R.string.toast_history, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      case R.id.Map_Menu_Science:
        startActivity(new Intent(this, MapsScience.class));
        Toast.makeText(this, R.string.toast_science, Toast.LENGTH_LONG).show();
        this.finish();
        return true;

      default:
        return super.onOptionsItemSelected(item);
    }
  }
示例#4
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   if (item.getItemId() == R.id.about) {
     Intent intent = new Intent(this, About.class);
     startActivity(intent);
   } else if (item.getItemId() == R.id.changeToSatellite) {
     if (map.isSatellite()) map.setSatellite(false);
     else map.setSatellite(true);
   }
   return true;
 }
示例#5
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.mymap);
    FrameLayout frame = (FrameLayout) findViewById(R.id.frame);

    //
    // TODO --> revisar la API Key, esta es la de produccion
    //
    mMapView = new MapView(this, "0cbsCnwzkViQZwFgU2Coie94cLA__ycwQxX3pqg");
    // mMapView = new MapView(this, "0slLUwYJ2HzIjfqA-mmYITQe45PnAN2BnvBuWog");
    frame.addView(
        mMapView, new FrameLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    // Create an overlay to show current location
    mMyLocationOverlay = new MyLocationOverlay(this, mMapView);
    mMyLocationOverlay.runOnFirstFix(
        new Runnable() {
          public void run() {
            mMapView.getController().animateTo(mMyLocationOverlay.getMyLocation());
          }
        });
    mMyLocationOverlay.enableCompass();

    mMapView.getOverlays().add(mMyLocationOverlay);
    mMapView.getController().setZoom(17);
    mMapView.setClickable(true);
    mMapView.setEnabled(true);
    mMapView.setSatellite(true);
    mMapView.setBuiltInZoomControls(true);
  }
 /**
  * When satellite mode is clicked by the user.
  *
  * @param view The satellite view.
  */
 public void onSatModeClicked(View view) {
   mMapView.setSatellite(true);
   mMapView.setTraffic(false);
   view.setEnabled(false);
   mMapModeView.setEnabled(true);
   mTrafficModeView.setEnabled(true);
 }
 /** @see android.app.Activity#onOptionsItemSelected(android.view.MenuItem) */
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case 0:
       // Zoom in
       zoomIn();
       return true;
     case 1:
       // Zoom out
       zoomOut();
       return true;
     case 2:
       // Toggle satellite views
       mvMap.setSatellite(!mvMap.isSatellite());
       return true;
     case 3:
       // Toggle street views
       mvMap.setStreetView(!mvMap.isStreetView());
       return true;
     case 4:
       // Toggle traffic views
       mvMap.setTraffic(!mvMap.isTraffic());
       return true;
     case 5:
       // Show the job list activity
       startActivity(new Intent(MicroJobs.this, MicroJobsList.class));
       return true;
   }
   return false;
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mProxymityBroadcast = new ProxymityBroadcast();
    mapView = (MapView) findViewById(R.id.mapView);
    mapView.setClickable(true);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(true);
    myLocaltionOverlay = new MyLocationOverlay(this, mapView);
    termini = new GeoPoint(41901222, 12500882);
    piazzadellarepubblica = new GeoPoint(41902622, 12495482);
    colosseo = new GeoPoint(41890310, 12492410);
    casaromoloeremo = new GeoPoint(41890492, 12484823);
    myLocaltionOverlay.runOnFirstFix(
        new Runnable() {

          @Override
          public void run() {
            mapView.getController().animateTo(myLocaltionOverlay.getMyLocation());
            mapView.getController().setZoom(14);
          }
        });
    prima = new RadiusOverlay(termini, 400, android.graphics.Color.BLUE);
    seconda = new RadiusOverlay(piazzadellarepubblica, 300, android.graphics.Color.BLUE);
    terza = new RadiusOverlay(colosseo, 500, android.graphics.Color.BLUE);
    quarta = new RadiusOverlay(casaromoloeremo, 450, android.graphics.Color.BLUE);
    mapView.getOverlays().add(prima);
    mapView.getOverlays().add(seconda);
    mapView.getOverlays().add(terza);
    mapView.getOverlays().add(quarta);
    mapView.getOverlays().add(myLocaltionOverlay);
  }
示例#9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabs);

    // Adding the zoom option
    mapView = (MapView) findViewById(R.id.MapView);
    LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom);
    View zoomView = mapView;

    zoomLayout.addView(
        zoomView,
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    mapView.displayZoomControls(true);

    mc = mapView.getController();
    String coordinates[] = {"32.2217429", " -110.926479"};
    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);

    p = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));

    mc.animateTo(p);
    mc.setZoom(10);
    mapView.invalidate();
    mapView.setSatellite(false);
    mapView.setStreetView(false);
    // bTakePicture = (Button)findViewById(R.id.bTakePicture);
    // bTakePicture.setOnClickListener(this);
  }
示例#10
0
 // Execute option's action based on user click.
 @Override
 public boolean onOptionsItemSelected(MenuItem optionItem) {
   super.onOptionsItemSelected(optionItem);
   switch (optionItem.getItemId()) {
     case (MAP_VIEW):
       {
         map.setSatellite(false);
         return true;
       }
     case (SAT_VIEW):
       {
         map.setSatellite(true);
         return true;
       }
   }
   return false;
 }
示例#11
0
 private void setupMap() {
   mapView = (MapView) findViewById(R.id.mapLocation);
   mapView.setBuiltInZoomControls(true);
   mapView.setSatellite(false);
   mc = mapView.getController();
   drawable = this.getResources().getDrawable(R.drawable.arrow);
   list = mapView.getOverlays();
   mc.setZoom(15); // 1 ~ 21
 }
示例#12
0
 /** Chage View Mode Map */
 private void changeMapMode() {
   mMode = !mMode;
   if (mMode) {
     mBtnMode.setText(R.string.googlemap_sattelite);
   } else {
     mBtnMode.setText(R.string.googlemap_map);
   }
   mapView.setSatellite(mMode);
 }
示例#13
0
  private void initMapView() {
    mapView = (MapView) findViewById(R.id.mapview);
    mapCtrl = mapView.getController();

    final int maxZoomLevel = mapView.getMaxZoomLevel() - zoomCorrection;
    mapCtrl.setZoom(maxZoomLevel);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(true);
  }
示例#14
0
 public boolean onKeyDown(int keyCode, KeyEvent e) {
   if (keyCode == KeyEvent.KEYCODE_S) {
     mapView.setSatellite(!mapView.isSatellite());
     return true;
   } else if (keyCode == KeyEvent.KEYCODE_T) {
     mapView.setTraffic(!mapView.isTraffic());
     mapControl.animateTo(gp); // To ensure change displays immediately
   }
   return (super.onKeyDown(keyCode, e));
 }
示例#15
0
 private void initMapView() {
   map = (MapView) findViewById(R.id.map);
   controller = map.getController();
   map.setSatellite(false);
   map.setBuiltInZoomControls(false);
   List<Overlay> capas = map.getOverlays();
   OverlayMap om = new OverlayMap(this);
   capas.add(om);
   map.postInvalidate();
 }
示例#16
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) { // click zoom key
   if (keyCode == KeyEvent.KEYCODE_S) {
     map.setSatellite(!map.isSatellite());
     return (true);
   } else if (keyCode == KeyEvent.KEYCODE_Z) {
     map.displayZoomControls(true);
     return (true);
   }
   return (super.onKeyDown(keyCode, event));
 }
示例#17
0
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.map_google_view);

    mBtnMode = (Button) findViewById(R.id.btnMode);
    mBtnMode.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            changeMapMode();
          }
        });

    mBtnFilter = (Button) findViewById(R.id.btnFilter);
    mBtnFilter.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            showDialog(DIALOG_FITER);
          }
        });

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(mMode);

    r = this.getResources();

    // Show All building by default
    for (int i = 0; i < checkedItems.length; i++) {
      checkedItems[i] = true;
    }

    parent = (KPIActivity) getParent();

    projection = mapView.getProjection();
    mc = mapView.getController();
    kpiIcon = BitmapFactory.decodeResource(r, R.drawable.icon);

    // mapOverlays = mapView.getOverlays();
    // mapOverlays.add(new MapOverlay());

    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = r.getDrawable(R.drawable.map_marker);
    MapItemOverlay itemOverlay = new MapItemOverlay(drawable, this);

    loadFaculties(itemOverlay);
    mapOverlays.add(itemOverlay);

    init();
  }
  // public constructor for BearingFrameLayout
  public BearingFrameLayout(Context context, String apiKey) {
    super(context); // call super constructor

    mapView = new MapView(context, apiKey); // create new MapView
    mapView.setClickable(true); // allow user interactions with the map
    mapView.setEnabled(true); // enables the MapView to generate events
    mapView.setSatellite(false); // display map image
    mapView.setBuiltInZoomControls(true); // enable zoom controls

    // set MapView's layout
    mapView.setLayoutParams(getChildLayoutParams());
    addView(mapView); // add MapView to this layout
  } // end BearingFrameLayout constructor
示例#19
0
  @SuppressLint("NewApi")
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_map);

    // Check for Geocoder
    geocoderAvailable =
        Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD && Geocoder.isPresent();

    // Get the Map View and configure
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(true);
    mapController = mapView.getController();
    mapController.setZoom(18);

    // Handler for updating text fields on the UI like the lat/long and address
    handler =
        new Handler() {
          public void handleMessage(Message msg) {
            switch (msg.what) {
              case UPDATE_ADDRESS:
                mAddress.setText((String) msg.obj);
                break;
              case UPDATE_LATLNG:
                mLatLng.setText((String) msg.obj);
                break;
            }
          }
        };

    // Reference LocationManager object
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    // Create an overlay that shows current location
    myLocationOverlay = new MyLocationOverlay(this, mapView);
    mapView.getOverlays().add(myLocationOverlay);

    myLocationOverlay.runOnFirstFix(
        new Runnable() {
          public void run() {
            mapView.getController().animateTo(myLocationOverlay.getMyLocation());
          }
        });

    Drawable drawable =
        this.getResources().getDrawable(R.drawable.ic_maps_indicator_current_position);
    itemizedOverlay = new MyOverlays(this, drawable);
    createMarker();
  }
  @Override
  protected void onResume() {
    super.onResume();

    MapType mapType = WindMobile.readMapType(this);
    switch (mapType) {
      case STANDARD:
        mapView.setSatellite(false);
        break;
      case SATELLITE:
        mapView.setSatellite(true);
        break;

      default:
        mapView.setSatellite(false);
    }

    if (getClientFactory().needStationInfosUpdate()) {
      getWaitForStationInfos().execute();
    } else {
      setStationInfos(clientFactory.getStationInfosCache());
    }
  }
 /** Initialize the map view. Looks for Google Maps API key loaded from zomdroid.properties */
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Log.d(ZomDroid.TAG, "Initializing map");
   setContentView(R.layout.map);
   map = new MapView(this, getIntent().getStringExtra("mapKey"));
   setContentView(map, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
   map.setEnabled(true);
   map.setClickable(true);
   map.setSatellite(false);
   map.setBuiltInZoomControls(true);
   controller = map.getController();
   timer = new Timer(true);
 }
  private void setupWidgets() {

    myMap = (MapView) findViewById(R.id.my_map);
    myMap.setSatellite(true);

    movementDescription = (TextView) findViewById(R.id.movementDescription);

    xValue = (TextView) findViewById(R.id.valueX);
    yValue = (TextView) findViewById(R.id.valueY);
    zValue = (TextView) findViewById(R.id.valueZ);

    pitchValue = (TextView) findViewById(R.id.valuePitch);
    rollValue = (TextView) findViewById(R.id.valueRoll);
    yawValue = (TextView) findViewById(R.id.valueYaw);
  }
 /**
  * When traffic mode is clicked by the user.
  *
  * @param view The traffic view.
  */
 public void onTrafficModeClicked(View view) {
   if (mMapView.isTraffic()) {
     mMapView.setTraffic(false);
     mMapModeView.setEnabled(false);
     mSatelliteModeView.setEnabled(true);
   } else {
     // If Traffic mode is selected, show the traffic in Map Mode only.
     // If Map is already on satellite mode than automatically change it
     // to Map Mode and enable the traffic.
     mMapView.setTraffic(true);
     mMapView.setSatellite(false);
     mMapModeView.setEnabled(false);
     mTrafficModeView.setEnabled(false);
     mSatelliteModeView.setEnabled(true);
   }
 }
示例#24
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Get a reference to the MapView
    MapView myMapView = (MapView) findViewById(R.id.myMapView);

    // Get the Map View's controller
    mapController = myMapView.getController();

    // Configure the map display options
    myMapView.setSatellite(true);
    myMapView.setBuiltInZoomControls(true);

    // Zoom in
    mapController.setZoom(17);

    // Add the MyPositionOverlay
    positionOverlay = new MyPositionOverlay();
    List<Overlay> overlays = myMapView.getOverlays();
    overlays.add(positionOverlay);
    myMapView.postInvalidate();

    LocationManager locationManager;
    String svcName = Context.LOCATION_SERVICE;
    locationManager = (LocationManager) getSystemService(svcName);

    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setPowerRequirement(Criteria.POWER_LOW);
    criteria.setAltitudeRequired(false);
    criteria.setBearingRequired(false);
    criteria.setSpeedRequired(false);
    criteria.setCostAllowed(true);
    String provider =
        LocationManager.GPS_PROVIDER; // locationManager.getBestProvider(criteria, true);

    Location l = locationManager.getLastKnownLocation(provider);

    updateWithNewLocation(l);

    locationManager.requestLocationUpdates(provider, 2000, 10, locationListener);
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    global_app = (SupervisorApplication) getApplication();
    decimalFormat = new DecimalFormat("#.########");

    setContentView(R.layout.layout_default_map);
    searchButton = (Button) findViewById(R.id.search);
    searchButton.setOnClickListener(this);
    searchButton.setOnTouchListener(this);
    logo = (Button) findViewById(R.id.logo);
    logo.setOnClickListener(this);
    logo.setOnTouchListener(this);

    lastLocation = global_app.getLastLocation();
    // Log.d(TAG, "lastLocation: LAT: " + Double.toString(lastLocation.getLatitude()) + " LON: " +
    // Double.toString(lastLocation.getLongitude()));

    userMarker = getResources().getDrawable(R.drawable.me);
    currentMarker = getResources().getDrawable(R.drawable.current_marker);
    pendingMarker = getResources().getDrawable(R.drawable.pending_marker);
    doneMarker = getResources().getDrawable(R.drawable.done_marker);
    cancelMarker = getResources().getDrawable(R.drawable.cancel_marker);

    try {
      taskId = getIntent().getExtras().getLong("taskId");
      Log.d(TAG + "task id", Long.toString(taskId));
      animateToTaskPosition = true;
    } catch (NullPointerException e) {
      animateToTaskPosition = false;
    }

    mapView = (MapView) findViewById(R.id.map);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(false);

    mapController = mapView.getController();
    mapController.setZoom(16);

    receiver = new TaskUpdateReceiver();
    filter = new IntentFilter(SupervisorApplication.UPDATE_VIEW_INTENT);
    registerReceiver(receiver, filter);
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   mMapView = (MapView) findViewById(R.id.mapview);
   mSearchEditText = (EditText) findViewById(R.id.searchtext);
   mMapController = mMapView.getController();
   mControlPanel = (RelativeLayout) findViewById(R.id.control_panel);
   mMapModeView = (ImageView) findViewById(R.id.map_mode);
   mSatelliteModeView = (ImageView) findViewById(R.id.sat_mode);
   mTrafficModeView = (ImageView) findViewById(R.id.traffic_mode);
   mSearchbar = (LinearLayout) findViewById(R.id.searchbar);
   // Pre-load the tiles so that maps can get loaded faster.
   mMapView.preLoad();
   // Turn on the map mode and set the zoom level.
   mMapController.setZoom(MAP_ZOOM_LEVEL);
   mMapView.setSatellite(false);
   mMapView.setBuiltInZoomControls(true);
   mSearchEditText.setFocusable(true);
   setSearchEditorActionListner();
 }
示例#27
0
  private void updateMapView() {
    int intZoomLevel = 17;
    MapView mapView = (MapView) findViewById(0 /*R.id.map*/);
    mapController = mapView.getController();
    mapView.setSatellite(false);
    mapView.setStreetView(true);
    mapView.setTraffic(true);

    geoPoint = new GeoPoint((int) (dLat), (int) (dLng /* * 1E6*/)); // 將剛剛取得的座標置入geoPoint
    mapView.displayZoomControls(true);
    mapView.setBuiltInZoomControls(true);

    mapController.animateTo(geoPoint); // 將map的中心點移到自己所在的位置
    mapController.setZoom(intZoomLevel); // 設定地圖級距

    // 加入地圖標籤
    MyLocationOverlay mapOverlay = new MyLocationOverlay(context, mapView);
    List listOfOverlays = mapView.getOverlays();
    listOfOverlays.clear();
    listOfOverlays.add(mapOverlay);
  }
示例#28
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE); // Suppress title bar to give more space
    setContentView(R.layout.show_the_map);

    initiateLocation();

    // Add map controller with zoom controls
    mapView = (MapView) findViewById(R.id.mv);
    mapView.setSatellite(true);
    mapView.setTraffic(false);
    mapView.setBuiltInZoomControls(true); // Set android:clickable=true in main.xml
    int maxZoom = mapView.getMaxZoomLevel();
    int initZoom = (int) (0.80 * (double) maxZoom);
    mapControl = mapView.getController();
    mapControl.setZoom(initZoom);
    // Convert lat/long in degrees into integers in microdegrees
    latE6 = (int) (lat * 1e6);
    lonE6 = (int) (lon * 1e6);
    gp = new GeoPoint(latE6, lonE6);
    mapControl.animateTo(gp);
  }
示例#29
0
  public void init() {

    LogManager.d("init");

    geoBeijing = new GeoPoint((int) (39.932 * 1000000), (int) (116.461 * 1000000));
    mDefaultCurrentLocation =
        new GeoPoint((int) (41.892910 * 1000000), (int) (12.48251990 * 1000000));

    mapView = (MapView) findViewById(R.id.map_view);
    map_view_enable = findViewById(R.id.map_view_enable);
    mapView.getLayoutParams().height = BaseActivity.screen_height * 1 / 2;
    map_view_enable.getLayoutParams().height = BaseActivity.screen_height * 1 / 2;
    mapView.setOnTouchListener(this);
    mapView.setSaveEnabled(true);
    mapView.setBuiltInZoomControls(false);

    mapCon = mapView.getController();
    mapCon.setZoom(defaultZoom);

    // geo = new Geocoder(getContext(), Locale.CHINA);
    mapCon.setCenter(mDefaultCurrentLocation);
    mapView.setTraffic(false);
    mapView.setSatellite(false);

    mPopView = (ViewGroup) mapActivity.getLayoutInflater().inflate(R.layout.map_popover, null);

    // MapActivity mapActivity = (MapActivity)getContext();
    // WindowManager windowManager = mapActivity.getWindowManager();
    // int width = windowManager.getDefaultDisplay().getWidth();

    mapView.addView(
        mPopView,
        new MapView.LayoutParams(
            LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT,
            null,
            MapView.LayoutParams.TOP_LEFT));
    mPopView.setVisibility(View.GONE);
    overlays = mapView.getOverlays();

    Drawable currentLocationMarker =
        this.getContext().getResources().getDrawable(R.drawable.user_location);
    mCurrentLocationOverlay = new MapItemizedOverlay(currentLocationMarker, this);
    mCurrentLocationOverlay.showPop = false;
    Drawable search = this.getContext().getResources().getDrawable(R.drawable.pin);

    bankOverlay = new MapItemizedOverlay(search, this);

    overlays.add(mCurrentLocationOverlay);
    overlays.add(bankOverlay);

    locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);

    mLocationListener1 =
        new LocationListener() {
          public void onLocationChanged(Location location) {
            Log.e(
                "Location",
                "GPSListener  "
                    + "latitude:"
                    + Double.toString(location.getLatitude())
                    + " longtitude:"
                    + Double.toString(location.getLongitude())
                    + " from:"
                    + location.getProvider());
            if (isBetterLocation(location, mCurrentLocation)) {
              setCurrentLocation(location);
              if (mMapShowingForLocationUpdate) {
                addCurrentLocationOverlay();
              }
            }
          }

          public void onStatusChanged(String provider, int status, Bundle extras) {}

          public void onProviderEnabled(String provider) {}

          public void onProviderDisabled(String provider) {}
        };

    mLocationListener2 =
        new LocationListener() {
          private boolean mFirstLaunch;

          public void onLocationChanged(Location location) {
            Log.e(
                "Location",
                "NetworkListener  "
                    + "latitude:"
                    + Double.toString(location.getLatitude())
                    + " longtitude:"
                    + Double.toString(location.getLongitude())
                    + " from:"
                    + location.getProvider());
            if (isBetterLocation(location, mCurrentLocation)) {
              setCurrentLocation(location);
              if (mMapShowingForLocationUpdate) {
                addCurrentLocationOverlay();
              }
            }
            if (mFirstLaunch == true) {
              mFirstLaunch = false;
              locationManager.removeUpdates(mLocationListener2);
            }
          }

          public void onStatusChanged(String provider, int status, Bundle extras) {}

          public void onProviderEnabled(String provider) {}

          public void onProviderDisabled(String provider) {}
        };
    myLocation = (ImageButton) findViewById(R.id.my_location);
    mapLayer = (ImageButton) findViewById(R.id.map_layer);
    showItems = (ImageButton) findViewById(R.id.show_items);
    searchButton = (ImageButton) findViewById(R.id.search_btn);
    searchEdt = (EditText) findViewById(R.id.search_input);
    distance_input = (EditText) findViewById(R.id.distance_input);
    if (App.app.initValue) {

      searchEdt.setText("05387");

      searchEdt.setText("via del tintoretto,200,roma");
    }

    searchButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // BaseMapActivity baseactivity = (BaseMapActivity)getContext();
            // baseactivity.hideKeyboard(searchButton);
            KeyBoardUtils.hideSoftInputFromWindow(mapActivity, searchEdt.getWindowToken());
            ProgressOverlay progressOverlay = new ProgressOverlay(getContext());
            progressOverlay.show(
                "searching...",
                new OnProgressEvent() {

                  @Override
                  public void onProgress() {

                    // Locale locale =
                    // getResources().getConfiguration().locale;

                    final String keyText = searchEdt.getText().toString();
                    searchGeoPoint = searchLocation(keyText);
                    if (searchGeoPoint != null) {
                      searchBarch(keyText);
                    }
                  }
                });
          }
        });

    mapLayer.setOnClickListener(
        new OnClickListener() {

          int i;

          @Override
          public void onClick(View v) {

            i++;
            int value = i % 2;
            switch (value) {
              case 0:
                mapView.setTraffic(false);
                mapView.setSatellite(false);
                break;
              case 1:
                mapView.setTraffic(false);
                mapView.setSatellite(true);

                break;
            }
          }
        });
    showItems.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (enter_distance_layout.getVisibility() == View.VISIBLE) {
              enter_distance_layout.setVisibility(View.GONE);
            } else {

              enter_distance_layout.setVisibility(View.VISIBLE);
            }
          }
        });
    myLocation.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            goToMyLocation();
          }
        });
    handler = new Handler();
    enter_distance_layout = (ViewGroup) findViewById(R.id.enter_distance_layout);
  }
  /**
   * Called when the activity is first created.
   *
   * @see com.google.android.maps.MapActivity#onCreate(android.os.Bundle)
   */
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // start trace
    // Debug.startMethodTracing("x");
    Debug.startMethodTracing("/data/data/com.microjobsinc.mjandroid/x.trace");
    setContentView(R.layout.main);

    db = new MicroJobsDatabase(this);

    // Get current position
    // The LocationManager is a special class that
    // Android instantiates for you, and you can retrieve the
    // instance for your application through the call to
    // getSystemService.
    final Location myLocation =
        getCurrentLocation((LocationManager) getSystemService(Context.LOCATION_SERVICE));

    Spinner spnLocations = (Spinner) findViewById(R.id.spnLocations);

    // Connect the Java MapView to the attributes defined for it in
    // main.xml, and
    mvMap = (MapView) findViewById(R.id.mapmain);
    // Get the map controller
    final MapController mc = mvMap.getController();
    // Create a LocationOverlay that will build and draw the Map in our
    // MapView when we want to view a map of our local area.
    mMyLocationOverlay = new MyLocationOverlay(this, mvMap);
    mMyLocationOverlay.enableMyLocation();
    // The first thing we do with mMyLocationOverlay is define
    // a method that Android will call when we receive our first
    // location fix from the location provider
    mMyLocationOverlay.runOnFirstFix(
        new Runnable() {
          public void run() {
            // move the map to the current location (given by
            // mMyLocationOverlay.getMyLocation()
            mc.animateTo(mMyLocationOverlay.getMyLocation());
            mc.setZoom(16);
          }
        });
    // Identify a marker to use on mMyLocationOverlay to mark
    // available jobs
    Drawable marker = getResources().getDrawable(R.drawable.android_tiny_image);
    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    // add the marker overlay to the list of overlays for the MapView mvMap.
    mvMap.getOverlays().add(new MJJobsOverlay(marker));
    // set some initial attributes for mvMap
    // We want users to be able to click(tap) on
    // a job to display more detail about this job
    mvMap.setClickable(true);
    // This method is inherited from android.view.View
    // it enables the standard map functions(zooming, panning)
    mvMap.setEnabled(true);
    // Setting this flag adds a satellite view
    mvMap.setSatellite(false);
    mvMap.setTraffic(false);
    mvMap.setStreetView(false);

    // start out with a general zoom
    mc.setZoom(16);
    mvMap.invalidate();

    // Create a button click listener for the List Jobs button.
    Button btnList = (Button) findViewById(R.id.btnShowList);
    btnList.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(MicroJobs.this.getApplication(), MicroJobsList.class);
            startActivity(intent);
          }
        });

    // A list of favorite locations that the Spinner will
    // display and the user can select
    List<String> lsLocations = new ArrayList<String>();
    // Load a HashMap with locations and positions
    final HashMap<String, GeoPoint> hmLocations = new HashMap<String, GeoPoint>();
    hmLocations.put("Current Location", new GeoPoint(latitude, longitude));
    lsLocations.add("Current Location");

    // Add favorite locations from this user's record in workers table
    worker = db.getWorker();
    hmLocations.put(
        worker.getColLoc1Name(),
        new GeoPoint((int) worker.getColLoc1Lat(), (int) worker.getColLoc1Long()));
    lsLocations.add(worker.getColLoc1Name());
    hmLocations.put(
        worker.getColLoc2Name(),
        new GeoPoint((int) worker.getColLoc2Lat(), (int) worker.getColLoc2Long()));
    lsLocations.add(worker.getColLoc2Name());
    hmLocations.put(
        worker.getColLoc3Name(),
        new GeoPoint((int) worker.getColLoc3Lat(), (int) worker.getColLoc3Long()));
    lsLocations.add(worker.getColLoc3Name());
    // Spinner views require an ArrayAdapter to feed them the list,
    // attaching the list of locations to the ArrayAdapter
    ArrayAdapter<String> aspnLocations =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, lsLocations);
    // Provide the Spinner with the drop-down layout necessary for the user
    // to display the whole list of locations.
    aspnLocations.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spnLocations.setAdapter(aspnLocations);

    // Setup a callback for the spinner
    spnLocations.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          public void onNothingSelected(AdapterView<?> arg0) {}
          // Enables the appropriate action when the user clicks on an item
          public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
            TextView vt = (TextView) v;
            if ("Current Location".equals(vt.getText())) {
              mMyLocationOverlay.enableMyLocation();
              try {
                mc.animateTo(mMyLocationOverlay.getMyLocation());
              } catch (Exception e) {
                Log.i("MicroJobs", "Unable to animate map", e);
              }
              mvMap.invalidate();
            } else {
              mMyLocationOverlay.disableMyLocation();
              mc.animateTo(hmLocations.get(vt.getText()));
            }
            mvMap.invalidate();
          }
        });
  }