示例#1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.findlocation);
    Log.i(TAG, "After View");
    btnSearch = (Button) findViewById(R.id.btnSearch);
    userText = (EditText) findViewById(R.id.edtxtLocation);
    Log.i(TAG, "After Fields");
    // showing the map
    mapv = (MapView) findViewById(R.id.mapvew);
    // getting values from bundle instance
    Bundle b = getIntent().getExtras();
    // double lat = Double.parseDouble("31.5497222");
    // double lng = Double.parseDouble("74.3436111");
    double lat = b.getDouble("lat");
    double lng = b.getDouble("lng");

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

    mapv.getController().setCenter(gp);
    // mapv.getController().setZoom(13);
    mapv.getController().animateTo(gp);

    gc = new Geocoder(this);
    Log.i(TAG, "B4 Listener");
    btnSearch.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            if (userText.length() == 0) {
              // Toast.makeText(getBaseContext(), "Enter Location !", Toast.LENGTH_LONG).show();
              AlertMessage2Show("Enter Location Name To Search");
            } else {
              String locn = userText.getText().toString();
              try {
                List<Address> addressList = gc.getFromLocationName(locn, 5);
                if (addressList != null && addressList.size() > 0) {

                  double lat = addressList.get(0).getLatitude();
                  double lng = addressList.get(0).getLongitude();
                  Toast.makeText(
                          getBaseContext(),
                          "New Latitude : " + lat + " && Longitude : " + lng,
                          Toast.LENGTH_LONG)
                      .show();
                  gp = new GeoPoint((int) (lat * 1E6), (int) (lng * 1E6));
                  mapv.getController().animateTo(gp);
                } else {

                  AlertMessage2Show("No Location Found !");
                }
              } catch (IOException e) {
                e.printStackTrace();
              }
            }
          }
        });
  }
 protected void trackUserLocation() {
   // Acquire a reference to the system Location Manager
   Criteria criteria = new Criteria();
   criteria.setAccuracy(Criteria.ACCURACY_COARSE);
   String bestProvider = locationManager.getBestProvider(criteria, true);
   Log.i(TAG, "Best Provider: " + bestProvider);
   Location lastKnownLocation = locationManager.getLastKnownLocation(bestProvider);
   requestLocations();
   mapView.getController().setZoom(16);
   Log.i(TAG, "lastLocation");
   lastLocation = lastKnownLocation;
   Log.i(TAG, "showUserMarker");
   showUserMarker(lastKnownLocation);
   GeoPoint point = toGeoPoint(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude());
   mapView.getController().animateTo(point);
 }
示例#3
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);
  }
示例#4
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);
  }
示例#5
0
    public void draw(android.graphics.Canvas canvas, MapView mapView, boolean shadow) {
      super.draw(canvas, mapView, false);

      // Disable unzooming map more than level 14, there will be to many
      // stations in map view
      if (mapView.getZoomLevel() < 14) mapView.getController().setZoom(14);
    }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Displaying Zooming controls
    MapView mapView = (MapView) findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);

    MapController mc = mapView.getController();
    double lat = Double.parseDouble("10.35410"); // latitude
    double lon = Double.parseDouble("123.91145"); // longitude
    GeoPoint geoPoint = new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6));
    mc.animateTo(geoPoint);
    mc.setZoom(15);
    mapView.invalidate();

    List<Overlay> mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
    AddItemizedOverlay itemizedOverlay = new AddItemizedOverlay(drawable, this);

    OverlayItem overlayitem = new OverlayItem(geoPoint, "Hello", "Talamban Campus");

    itemizedOverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedOverlay);
  }
示例#7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.qtplace);

    // Set spinner content
    spnService = (Spinner) findViewById(R.id.spnPlace);
    ArrayAdapter<String> spnAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spnArr);
    spnAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spnService.setAdapter(spnAdapter);

    // Set mapview content
    mapView = (MapView) findViewById(R.id.map_view);
    mapController = mapView.getController();

    mapView.setBuiltInZoomControls(true);

    // Get prefrences
    mapController.animateTo(testpoint);
    mapController.setZoom(14);

    // Set current location
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    LocationListener ll = new myLocationListenner();
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);

    // Get distance
    txtDistance = (EditText) findViewById(R.id.txtDistance);

    // Set pointer in map
    mapOverlays = mapView.getOverlays();
    Drawable drawable = this.getResources().getDrawable(R.drawable.google_map_marker);
    itemizeOverlay = new CustomItemizeOverlay(drawable, this);
  }
  private void initMaps(UserInterface userInterface) {
    MapView mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    mapOverlays = mapView.getOverlays();
    hashMapOverlayItem = new HashMap<String, MapOverlayItem>();

    mMapsPinOrange = this.getResources().getDrawable(R.drawable.maps_pin_orange);
    int w = mMapsPinOrange.getIntrinsicWidth();
    int h = mMapsPinOrange.getIntrinsicHeight();
    mMapsPinOrange.setBounds(-w / 2, -h, w / 2, 0);

    mMapsPinGreen = this.getResources().getDrawable(R.drawable.maps_pin_green);
    mMapsPinGreen.setBounds(
        0, 0, mMapsPinGreen.getIntrinsicWidth(), mMapsPinGreen.getIntrinsicHeight());

    overlay = new MapItemnizedOverlay(mMapsPinGreen, this);

    mapController = mapView.getController();
    mapOverlays.add(overlay);

    mHandler.postDelayed(addMarker(userInterface), 200);
    if (UserManager.getInstance().thisUser().getGeoPoint() != null) {
      mHandler.postDelayed(addMarker(UserManager.getInstance().getThisUser()), 200);
    }
  }
 /** Zoom out on the map, but not past level 10 */
 private void zoomOut() {
   int zoom = mvMap.getZoomLevel() - 1;
   if (zoom < 5) {
     zoom = 5;
   }
   mvMap.getController().setZoom(zoom);
 }
示例#10
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // MapView and Controller
    map = (MapView) findViewById(R.id.map);
    map.setBuiltInZoomControls(true);
    myMapController = map.getController();
    myMapController.setZoom(17);

    // MyLocationOverlay
    myLocationOverlay = new MyLocationOverlay(this, map);
    myLocationOverlay.enableMyLocation();
    map.getOverlays().add(myLocationOverlay);

    // Get Overlays
    mapOverlays = map.getOverlays();
    drawable = this.getResources().getDrawable(R.drawable.marker);
    itemizedOverlay = new HelloItemizedOverlay(drawable);

    // Add Marker on RP E6
    GeoPoint point = new GeoPoint(1445450, 103784260);
    OverlayItem overlayitem = new OverlayItem(point, "Hello!", "This is Republic Polytechnic E6");

    itemizedOverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedOverlay);
  }
示例#11
0
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.maptab);
    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    layout1 = (LinearLayout) findViewById(R.id.maptab1);
    //		layout2 = (LinearLayout)findViewById(R.id.maptab2);

    BroadcastReceiver myReceiver =
        new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
            Toast.makeText(context, "브로드캐스팅", 1000).show();
            //				layout1.setVisibility(View.GONE);
            //				layout2.setVisibility(View.VISIBLE);
          }
        };
    IntentFilter filter = new IntentFilter("bbb");
    registerReceiver(myReceiver, filter);

    final MapController mc = mapView.getController();
    GeoPoint point = new GeoPoint(37298025, 126972817);
    mc.animateTo(point);
    mc.setZoom(16);

    putBoardMarker();
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maps);
    MapView mapView = (MapView) findViewById(R.id.mapview);
    handler = new Handler();
    this.activity = this;

    mapView.setBuiltInZoomControls(true);

    map = new HashMap<String, OverlayItem>();

    mapOverlays = mapView.getOverlays();

    pin_green = this.getResources().getDrawable(R.drawable.maps_pin_green);
    pin_green.setBounds(0, 0, pin_green.getIntrinsicWidth(), pin_green.getIntrinsicHeight());
    pin_orange = this.getResources().getDrawable(R.drawable.maps_pin_orange);
    pin_orange.setBounds(0, 0, pin_orange.getIntrinsicWidth(), pin_orange.getIntrinsicHeight());

    overlay = new MapItemnizedOverlay(pin_green, this);

    mapController = mapView.getController();
    mapOverlays.add(overlay);

    MessageOrchestrator.getInstance().addDrawManager(DRAWMANAGER_TYPE.MAP, this);
  }
示例#13
0
  private void init() {

    this.lblTitulo = (TextView) this.findViewById(R.id.mapa_titulo);

    final MapView mapa = (MapView) this.findViewById(R.id.mapa);
    mapa.setStreetView(true);

    final Intent intent = this.getIntent();
    if (intent != null) {

      final Object anuncio = intent.getSerializableExtra(ANUNCIO);
      if (anuncio != null) {

        this.anuncio = (Anuncio) anuncio;

        this.lblTitulo.setText(
            this.anuncio.getProduto().getNome() + " (" + this.anuncio.getValorFormatado() + ")");

        final GeoPoint ponto = new Ponto(this.anuncio.getLatitude(), this.anuncio.getLongitude());
        mapa.getOverlays().add(new PontoOverlay(ponto, R.drawable.guaraba_wally_30));
        mapa.getController().setZoom(18);
        mapa.getController().setCenter(ponto);
      }
    }
  }
示例#14
0
 @Override
 public void onStart() {
   super.onStart();
   mapController = mapView.getController();
   mapController.setCenter(homeLocation);
   mapOverlays = mapView.getOverlays();
   mapOverlays.add(new MapKeyOverlay(this, null, 0, null));
   mapView.invalidate();
 }
示例#15
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
 }
示例#16
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);
  }
示例#17
0
 public void updateHome() {
   try {
     stations.updateHome();
     mapView.getController().setCenter(stations.getHome().getPoint());
     mapView.getController().setZoom(16);
   } catch (Exception e) {
     //// Log.i("openBicing", "center is null..");
   }
 }
示例#18
0
  public void postRequestHandler(String result) {

    aButton.setEnabled(true);

    JSONObject json_obj;

    try {

      json_obj = new JSONObject(result);

      String slat = json_obj.getString("latitude");
      String slong = json_obj.getString("longitude");
      String countryname = json_obj.getString("country_name");
      String city = json_obj.getString("city");
      String region = json_obj.getString("region");

      double lat = Double.parseDouble(slat);
      double lon = Double.parseDouble(slong);

      GeoPoint gp = getPoint(lat, lon);
      mapView.getController().setZoom(9);
      mapView.getController().animateTo(gp);

      List<Overlay> mapOverlays = mapView.getOverlays();
      Drawable drawable = this.getResources().getDrawable(R.drawable.marker);
      SitesOverlay itemizedoverlay = new SitesOverlay(drawable, getApplicationContext());

      OverlayItem overlayitem = new OverlayItem(gp, ipaddress, ipaddress);

      itemizedoverlay.addOverlay(overlayitem);
      mapOverlays.add(itemizedoverlay);

      TextView textView = (TextView) findViewById(R.id.display);
      textView.setText(
          "Longitude = "
              + slat
              + " \nLongitude = "
              + slong
              + " \nCity = "
              + city
              + " \nRegion = "
              + region
              + " \nCountry = "
              + countryname);
      textView.setHorizontalScrollBarEnabled(true);

      Toast toast = Toast.makeText(getApplicationContext(), "Request has completed succesfully", 3);
      toast.show();

    } catch (JSONException e) {
      Toast toast =
          Toast.makeText(
              getApplicationContext(), "Unable to process request...please try again", 10);
      toast.show();
    }
  }
示例#19
0
  private void placeMarker(int markerLatitude, int markerLongitude) {

    Drawable marker = getResources().getDrawable(R.drawable.marker);

    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());
    mapView.getController().setZoom(14);

    mapView.setBuiltInZoomControls(true);
    mapView.getOverlays().add(new MapMarker(marker, markerLatitude, markerLongitude));
  }
示例#20
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();
 }
 public void scrollToCurrentLocation() {
   LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
   Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
   if (location != null) {
     int latitude = (int) (location.getLatitude() * 1E6);
     int longitude = (int) (location.getLongitude() * 1E6);
     GeoPoint point = new GeoPoint(latitude, longitude);
     mapView.getController().setZoom(selectionZoomLevel);
     mapView.getController().setCenter(point);
   }
 }
示例#22
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mapV = (MapView) findViewById(R.id.mapView);

    mapV.displayZoomControls(true);
    mapV.setBuiltInZoomControls(true);
    mapV.setSaveEnabled(true);

    initlocation.setLatitude(0.1);
    initlocation.setLongitude(0.1);

    GeoP =
        new GeoPoint(
            (int) (initlocation.getLatitude() * 1E6), (int) (initlocation.getLongitude() * 1E6));

    posOverlay = new MapOverlay();
    List<Overlay> overlays = mapV.getOverlays();
    overlays.add(posOverlay);

    mControl = mapV.getController();
    mControl.animateTo(GeoP);
    mControl.setZoom(5);

    Bitmap iss = BitmapFactory.decodeResource(getResources(), R.drawable.iss);
    Bitmap logo = BitmapFactory.decodeResource(getResources(), R.drawable.logo);
    Bitmap logotext = BitmapFactory.decodeResource(getResources(), R.drawable.logotext);
    Bitmap tracker = BitmapFactory.decodeResource(getResources(), R.drawable.isstracker);
    posOverlay.SetImages(iss, logo, logotext, tracker);
    posOverlay.setLocation(initlocation);

    if (CheckNetwork(getApplicationContext())) {
      startUpdateTimer();
    } else {
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setMessage(
          "No data connection found, please check you have a mobile data connection or wifi enabled.");
      builder.setNegativeButton(
          "Quit",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
              dialog.cancel();
              finish();
            }
          });
      AlertDialog alert = builder.create();

      alert.show();
    }
  }
示例#23
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();
  }
  @Override
  public boolean onTouchEvent(MotionEvent event, MapView mapView) {
    switch (event.getAction()) {
      case MotionEvent.ACTION_DOWN:
        if ((System.currentTimeMillis() - systemTime) < 250) {
          mapView.getController().zoomIn();
        }
        systemTime = System.currentTimeMillis();
        break;
    }

    return false;
  }
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   MapController mc = mapView.getController();
   switch (keyCode) {
     case KeyEvent.KEYCODE_I:
       mc.zoomIn();
       break;
     case KeyEvent.KEYCODE_O:
       mc.zoomOut();
       break;
   }
   return super.onKeyDown(keyCode, event);
 }
示例#26
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
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    map = (MapView) findViewById(R.id.mvMain);
    map.setBuiltInZoomControls(true);
    Touchy t = new Touchy(); // Overlay para detectar toques en lapantalla
    oveList = map.getOverlays(); // obtiene todos los overlays que se dibujan en el mapa
    oveList.add(t); // agrega nuestro overlay de ultimo en la lista
    compass =
        new MyLocationOverlay(
            MainActivity.this, map); // se crea un nuevo Overlay de la localizacion actual
    oveList.add(compass); // se agrega el overlay de la localizacion
    controller = map.getController(); // se obtinenen los controles del mapa
    GeoPoint point = new GeoPoint(51643234, 7848593); // se crea un nuevo Geopoint
    controller.animateTo(point); // se indica a los controles que nos lleven al punto indicado
    controller.setZoom(6); // se hace un zoon de nivel 6
    d =
        getResources()
            .getDrawable(
                R.drawable.ic_launcher); // se crea un objeto dibujable por medio de un recurso

    // placing pintpoint at location
    lm =
        (LocationManager)
            getSystemService(Context.LOCATION_SERVICE); // manager para la localizacion GPS
    Criteria crit =
        new Criteria(); // un objeto criterio que maneja el mejor criterio de selleccion del
    // provider
    towers = lm.getBestProvider(crit, false); // se obtiene un proveedor de localizacion
    Location location =
        lm.getLastKnownLocation(towers); // se obtine la localizacion del provedor seleccionado

    // si hay una localizacion
    if (location != null) {
      lat = (int) location.getLatitude(); // se obtiene la lat  y long
      lon = (int) location.getLongitude();
      GeoPoint ourLocation = new GeoPoint(lat, lon); // se crea un nuevo punto
      // se crea un overlay para mostrar un dibujo en el punto indicado por la lat y lon
      OverlayItem overlayItem = new OverlayItem(ourLocation, "what's up", "2nd string");
      CustonPinpoint custom =
          new CustonPinpoint(
              d, MainActivity.this); // se crea un punto personal con el objeto dibujable
      custom.insertPinpoint(overlayItem); // se le dan los datos de la posicion en el mapa
      oveList.add(custom); // se agrega el punto en la lista de overlays
    } else {
      // cuando todo se va al carajo
      Toast.makeText(MainActivity.this, "no se puede encontrar un provider", Toast.LENGTH_LONG)
          .show();
    }
  }
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   final MapView mapView = (MapView) findViewById(R.id.mapView);
   mapView.setBuiltInZoomControls(true);
   mapView.getZoomButtonsController().setAutoDismissed(false);
   mapView.displayZoomControls(true);
   overlay = new SampleBalloonItemizedOverlay(mapView);
   mapView.getOverlays().add(overlay);
   mapView.getController().animateTo(new GeoPoint(42431320, -8642187));
   mapView.getController().setZoom(16);
   mapView.invalidate();
 }
  private void inicializeMap() {
    mapView = (MapView) findViewById(R.id.map);
    mapView.setBuiltInZoomControls(true);
    mapController = mapView.getController();
    mapController.setZoom(16);
    if (latitud != 0 && longitud != 0) {
      int lat = (int) (latitud * 1E6);
      int lon = (int) (longitud * 1E6);

      mapController.animateTo(new GeoPoint(lat, lon));
      mapController.setCenter(new GeoPoint(lat, lon));
    }
    centerMyPosition();
  }
 /** 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);
 }