예제 #1
0
  @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);
  }
  public void onDetermined(ArrayList<GeoPoint> alPoint, ArrayList<Integer> alRadius) {
    GeoPoint oPoint = null;
    int oRadius = 0;

    // remove old radiusoverlays
    for (int i = 0; i < mapView.getOverlays().size(); i++) {
      RadiusOverlay mROtemp = new RadiusOverlay(oPoint, oRadius);
      Overlay Otemp = mapView.getOverlays().get(i);

      if (Otemp.getClass() == mROtemp.getClass()) {
        mapView.getOverlays().remove(Otemp);
        i--;
      }
    }

    // add new route overlays
    for (int i = 0; i < alPoint.size(); i++) {
      oPoint = alPoint.get(i);
      oRadius = alRadius.get(i);

      mapView.getOverlays().add(new RadiusOverlay(oPoint, oRadius));
    }

    mapView.invalidate();
  }
예제 #3
0
파일: WhereAmI.java 프로젝트: jubic/RP-Misc
  /** 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);
  }
예제 #4
0
  @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);
  }
예제 #5
0
파일: MapTab.java 프로젝트: ggrassi/challp
  private void initMyLocationOverlay() {
    myLocationOverlay =
        new MyLocationOverlay(this, mapView) {

          @Override
          public void onLocationChanged(Location newPosition) {
            super.onLocationChanged(newPosition);
            final GeoPoint myPosition =
                new GeoPoint(
                    (int) (newPosition.getLatitude() * 1E6),
                    (int) (newPosition.getLongitude() * 1E6));

            mapCtrl.animateTo(myPosition);
          }
        };

    mapView.getOverlays().add(myLocationOverlay);
    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableCompass();
    myLocationOverlay.runOnFirstFix(
        new Runnable() {

          public void run() {
            mapCtrl.animateTo(myLocationOverlay.getMyLocation());
          }
        });
  }
예제 #6
0
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    _finder = new AppEngineStationFinder();

    _searchThread = new SearcherThread(MainActivity.this, _searchRequestQueue);
    _searchThread.start();

    _uiThreadCallback = new Handler();

    initViewMembers();
    preloadIconBitmaps();

    _mapView.getOverlays().add(new TapListenerOverlay(this));

    _locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    initMyLocationOverview();

    registerLocationListener();

    if (!_locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
      buildAlertMessageNoGps();
    }

    useLastKnownLocation(_locationManager);
    Log.v(TAG, "On create finished");

    // updateLocation( 53.250721,10.433192 );

  }
  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);
    }
  }
예제 #8
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);
      }
    }
  }
예제 #9
0
 private void paintObjects() {
   Log.i(TAG, "paintObjects()");
   for (int i = 1; i < bikesArrayList.size(); i++) {
     JSONObject jo = bikesArrayList.get(i - 1);
     try {
       String title = jo.getString("title");
       String subtitle = jo.getString("subtitle");
       String lat = jo.getString("lat");
       String lon = jo.getString("lon");
       GeoPoint point = toGeoPoint(Double.parseDouble(lat), Double.parseDouble(lon));
       JsonOverlayItem overlayitem = new JsonOverlayItem(point, title, subtitle);
       overlayitem.setJo(jo);
       itemizedoverlay.addOverlay(overlayitem);
       if ((i % 100) == 0) {
         mapOverlays.add(itemizedoverlay);
         itemizedoverlay = new ObjectsItemizedOverlay(pushPinMarker, mapView);
         itemizedoverlay.setDestino(BikesDataActivity.class);
         // Log.e(TAG, "Nueva Capa");
       }
       // Log.i(TAG, (i+1)+"");
     } catch (JSONException e) {
       e.printStackTrace();
     }
   }
   Log.i(TAG, "Fin paintObjects()");
   Log.e(TAG, "Numero de Capas: " + mapView.getOverlays().size());
   runOnUiThread(returnRes);
 }
예제 #10
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);
  }
예제 #11
0
  @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);
  }
예제 #12
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);
  }
예제 #13
0
 private void createMarker() {
   GeoPoint p = mapView.getMapCenter();
   OverlayItem overlayItem = new OverlayItem(p, "", "");
   itemizedOverlay.addOverlay(overlayItem);
   if (itemizedOverlay.size() > 0) {
     mapView.getOverlays().add(itemizedOverlay);
   }
 }
 @Override
 protected void onDeviceLocationsChanged(Map<String, GeoPoint> deviceLocations) {
   List<Overlay> overlays = mMapView.getOverlays();
   overlays.clear();
   for (GeoPoint point : deviceLocations.values()) {
     overlays.add(new IconOverlay(point));
   }
 }
예제 #15
0
 @Override
 protected void onPostExecute(MapItemOverlay result) {
   List<Overlay> mapOverlays = mapView.getOverlays();
   mapOverlays.clear();
   mapOverlays.add(result);
   mapView.invalidate();
   dialog.dismiss();
 }
예제 #16
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();
 }
예제 #17
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
 }
예제 #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();
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    MapView earthquakeMap = ((Earthquake) getActivity()).mapView;
    eo = new EarthquakeOverlay(null);
    earthquakeMap.getOverlays().add(eo);

    return earthquakeMap;
  }
예제 #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();
 }
예제 #21
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));
  }
예제 #22
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    map = (MapView) findViewById(R.id.map);

    map.getController().setCenter(getPoint(40.76793169992044, -73.98180484771729));
    map.getController().setZoom(17);
    map.setBuiltInZoomControls(true);

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

    marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());

    map.getOverlays().add(new SitesOverlay(marker));

    me = new MyLocationOverlay(this, map);
    map.getOverlays().add(me);
  }
 public void paintTasks() {
   allOverlays = mapView.getOverlays();
   allOverlays.remove(tasksPositionOverlay);
   tasksPositionOverlay = new TasksOverlay(doneMarker, this);
   tasksCursor = global_app.getDataStorage().getAllTasks();
   DecimalFormat km = new DecimalFormat();
   km.setMaximumFractionDigits(2);
   DecimalFormat m = new DecimalFormat();
   m.setMaximumFractionDigits(1);
   while (tasksCursor.moveToNext()) {
     double lat = tasksCursor.getDouble(tasksCursor.getColumnIndex(DataStorage.C_LAT));
     double lon = tasksCursor.getDouble(tasksCursor.getColumnIndex(DataStorage.C_LON));
     String taskTitle = (tasksCursor.getString(tasksCursor.getColumnIndex(DataStorage.C_NAME)));
     int taskState = (tasksCursor.getInt(tasksCursor.getColumnIndex(DataStorage.C_STATE)));
     int taskId = (tasksCursor.getInt(tasksCursor.getColumnIndex(DataStorage.C_ID)));
     GeoPoint taskLocation = new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6));
     Location tmp = new Location(provider);
     tmp.setLatitude(lat);
     tmp.setLongitude(lon);
     double distance = lastLocation.distanceTo(tmp);
     String prettyDistance;
     if (distance > 1000) prettyDistance = km.format(distance / 1000) + "km";
     else prettyDistance = m.format(distance) + "m";
     OverlayItem taskOverlayItem =
         new OverlayItem(
             taskLocation,
             taskTitle + " (id: " + Integer.toString(taskId) + ")",
             "oddalone o: " + prettyDistance);
     Drawable marker;
     switch (taskState) {
       case 0:
         marker = cancelMarker;
         break;
       case 1:
         marker = pendingMarker;
         break;
       case 2:
         marker = currentMarker;
         break;
       default:
         marker = doneMarker;
         break;
     }
     int w = marker.getIntrinsicWidth();
     int h = marker.getIntrinsicHeight();
     marker.setBounds(-w / 2, -h, w / 2, 0);
     taskOverlayItem.setMarker(marker);
     tasksPositionOverlay.addOverlay(taskOverlayItem);
   }
   allOverlays.add(tasksPositionOverlay);
   mapView.invalidate();
   tasksCursor.close();
 }
예제 #24
0
  private void initMyLocationOverview() {
    _myLocationOverlay = new MyLocationOverlay(this, _mapView);
    _myLocationOverlay.enableMyLocation();
    _myLocationOverlay.runOnFirstFix(
        new Runnable() {
          public void run() {
            updateLocation(_myLocationOverlay.getMyLocation());
          }
        });

    _mapView.getOverlays().add(_myLocationOverlay);
  }
예제 #25
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();
  }
예제 #26
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();
    }
  }
예제 #27
0
 private void initMyLocation() {
   overlay = new MyLocationOverlay(this, map);
   overlay.enableMyLocation();
   overlay.disableCompass();
   overlay.runOnFirstFix(
       new Runnable() {
         public void run() {
           controller.setZoom(14);
           controller.animateTo(overlay.getMyLocation());
         }
       });
   map.getOverlays().add(overlay);
 }
예제 #28
0
 protected void showUserMarker(Location location) {
   mapView.getOverlays().remove(userOverlay);
   userOverlay = (userItemizedOverlay) new userItemizedOverlay(userLocationMarker);
   GeoPoint point = toGeoPoint(location.getLatitude(), location.getLongitude());
   OverlayItem overlayitem = new OverlayItem(point, "", "");
   userOverlay.addOverlay(overlayitem);
   mapView.getOverlays().add(userOverlay);
   // double newLatitude = (double)Math.round(location.getLatitude() *
   // 10000000) / 10000000;
   // double newLongitude = (double)Math.round(location.getLongitude() *
   // 10000000) / 10000000;
   // double oldLatitude = (double)Math.round(lastLocation.getLatitude() *
   // 10000000) / 10000000;
   // double oldLongitude = (double)Math.round(lastLocation.getLongitude()
   // * 10000000) / 10000000;
   //
   // if(!(newLatitude == oldLatitude) || !(newLongitude == oldLongitude)){
   // lastLocation.setLongitude(newLongitude);
   // lastLocation.setLatitude(newLatitude);
   // mapView.getController().animateTo(point);
   // }
 }
  @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();
    }
  }
예제 #30
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();
  }