@Override
  public void onMapReady(GoogleMap googleMap) {
    Log.d(TAG, "Map Received");
    this.map = googleMap;
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (location != null) {
      map.animateCamera(
          CameraUpdateFactory.newLatLngZoom(
              new LatLng(location.getLatitude(), location.getLongitude()), 17));

      CameraPosition cameraPosition =
          new CameraPosition.Builder()
              .target(
                  new LatLng(
                      location.getLatitude(),
                      location.getLongitude())) // Sets the center of the map to location user
              .zoom(17) // Sets the zoom
              .bearing(90) // Sets the orientation of the camera to east
              .tilt(40) // Sets the tilt of the camera to 30 degrees
              .build(); // Creates a CameraPosition from the builder
      map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }
  }
  private void init() {
    cnt = 0;
    GooglePlayServicesUtil.isGooglePlayServicesAvailable(MapsActivity.this);
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    locationListener = new MyLocationListener();
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 2000, 10, locationListener);

    // GPS ������� ��������
    gps = new GPSInfo(MapsActivity.this);
    locationListener = new MyLocationListener();

    if (gps.isGetLocation()) {
      double latitude = gps.getLatitude();
      double longitude = gps.getLongitude();

      // Creating a LatLng object for the current location
      LatLng latLng = new LatLng(latitude, longitude);

      // Showing the current location in Google Map
      mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

      // Map �� zoom �մϴ�.
      mMap.animateCamera(CameraUpdateFactory.zoomTo(15));

      mMap.addMarker(new MarkerOptions().position(latLng).title("My"));
    }
  }
示例#3
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps_daus);
    MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.maps);

    mapFragment.getMapAsync(this);

    try {
      initializeMaps();
      gMaps.addMarker(
          new MarkerOptions()
              .icon(BitmapDescriptorFactory.fromResource(R.drawable.wisataa))
              .position(new LatLng(5.559382, 95.321629))
              .visible(true)
              .title("Nasi Goreng Daus"));
      gMaps.setMyLocationEnabled(true);
      CameraPosition cameraPosition =
          new CameraPosition.Builder().target(new LatLng(5.484702, 95.227189)).zoom(10).build();
      gMaps.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
      gMaps.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 2000, null);
    } catch (Exception e) {
    }
  }
 /** Sets the map view to center itself around the given user location geoPoint */
 public void setMapViewToLocation(LatLng latLng) {
   if (autoZoom) {
     googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, POSITION_ZOOM_LEVEL));
   } else {
     googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
   }
 }
示例#5
0
  private void drawCurrentLocation(LatLng current_location) {

    if (cLMarker != null) {
      cLMarker.remove();
    }

    cLMarker =
        googleMap.addMarker(
            markerOptions
                .position(current_location)
                .title("Current Position")
                .snippet("")
                .flat(true)
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));

    if (firstTimeCameraMove) {
      googleMap.animateCamera(CameraUpdateFactory.newLatLng(current_location));

      CameraPosition cameraPosition =
          new CameraPosition.Builder()
              .target(current_location) // Sets the center of the map to location user
              .zoom(17) // Sets the zoom
              .build(); // Creates a CameraPosition from the builder
      googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
      firstTimeCameraMove = false;
    }
  }
示例#6
0
  private void setUpMap() {

    if (showRoute == false) {
      mMap.addMarker(
          new MarkerOptions()
              .position(CAFETERIA)
              .title("Cafeteria")
              .snippet("Hochschule Karlsruhe"));
      mMap.moveCamera(CameraUpdateFactory.newLatLng(CAFETERIA));
      mMap.animateCamera(CameraUpdateFactory.zoomTo(17.00f));
    } else if (showRoute == true) {
      String uri =
          "http://maps.google.com/maps?saddr="
              + standortLatitude
              + ","
              + standortLongitude
              + "&daddr="
              + 49.01578
              + ","
              + 8.39137;
      Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
      intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
      startActivity(intent);
    }
  }
  @Override
  public void onConnected(Bundle bundle) {
    Log.i(TAG, "Location services connected.");

    Location lastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);

    if (lastLocation == null) {
      Toast.makeText(
              FullScreenMapActivity.this, "There is currently no connectivity", Toast.LENGTH_LONG)
          .show();
    } else {

      ParseGeoPoint point =
          new ParseGeoPoint(lastLocation.getLatitude(), lastLocation.getLongitude());
      ParseUser currentUser = ParseUser.getCurrentUser();
      currentUser.put("location", point);
      currentUser.saveInBackground();

      mGoogleMap.animateCamera(CameraUpdateFactory.zoomIn());

      CameraPosition cameraPosition =
          new CameraPosition.Builder()
              .target(new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()))
              .zoom(12)
              .bearing(90)
              .tilt(30)
              .build();

      mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }
  }
  public void changeMap(LatLng latLng) {
    // Show the current location in Google Map
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

    // Zoom in the Google Map
    mMap.animateCamera(CameraUpdateFactory.zoomTo(14));
  }
示例#9
0
 @Override
 public void onMapReady(GoogleMap googleMap) {
   LatLng latLng = new LatLng(23.156116, 113.445332);
   mMap.addMarker(new MarkerOptions().position(latLng).flat(true).title("Marker here"));
   mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
   mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
 }
示例#10
0
  @Override
  public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    // Add a marker in Sydney and move the camera
    ubicacion = new Ubicacion(MapsActivity.this);
    currentLatLng = ubicacion.latLng();
    localizacion = new Localizacion(MapsActivity.this, currentLatLng);

    information = Arrays.toString(localizacion.gps()).replaceAll("\\[|\\]", "");
    mMap.addMarker(
        new MarkerOptions()
            .position(currentLatLng)
            .draggable(true)
            .title(information)
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(currentLatLng));
    cameraUpdate = CameraUpdateFactory.newLatLngZoom((currentLatLng), 16);
    mMap.animateCamera(cameraUpdate);
    preferences =
        new Preferences(
            getApplicationContext(),
            "Latitude,Longitude,CountryCode,Country, State, City, Address",
            String.valueOf(currentLatLng.latitude)
                + ","
                + String.valueOf(currentLatLng.longitude)
                + ","
                + information,
            "Laundry");
    preferences.savePreferences();
    mMap.setOnMarkerDragListener(this);
  }
示例#11
0
  @Override
  public void onResume() {
    if (getMap() != null && getView() != null) {
      // Ponemos que inicie el mapa en el Kiosko de Surbus
      getMap().moveCamera(CameraUpdateFactory.newLatLng(coordenadas));
      getMap().setMapType(GoogleMap.MAP_TYPE_HYBRID);
      getMap().setMyLocationEnabled(true);
      getMap().setOnMyLocationChangeListener(this);
      getMap().moveCamera(CameraUpdateFactory.zoomTo(15));
      getMap()
          .setOnMarkerClickListener(
              new OnMarkerClickListener() {

                @Override
                public boolean onMarkerClick(Marker marker) {
                  synchronized (DataStorage.paradas) {
                    Parada p = DataStorage.paradas.get(Integer.parseInt(marker.getTitle()));
                    DialogFragment f = MostrarInfoParada.newInstance(p.getId());
                    f.show(getActivity().getSupportFragmentManager(), "Info");
                  }
                  return true;
                }
              });
      bitmapParada = BitmapDescriptorFactory.fromResource(R.drawable.bus_stop);
      buscarParadas();
    }
    super.onResume();
  }
示例#12
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layoutView = inflater.inflate(R.layout.map_frag, container, false);

    // Get the location manager
    locationManager = (LocationManager) myContext.getSystemService(Context.LOCATION_SERVICE);
    // Define the criteria how to select the locatioin provider -> use
    // default
    Criteria criteria = new Criteria();
    provider = locationManager.getBestProvider(criteria, false);
    Location location = locationManager.getLastKnownLocation(provider);
    LatLng latLng;
    if (location != null) {
      latLng = new LatLng(location.getLatitude(), location.getLongitude());
    } else {
      latLng = new LatLng(39.864052799999996, -75.12900809999996);
    }

    map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    // Move the camera instantly to hamburg with a zoom of 15.
    map.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));

    // Zoom in, animating the camera.
    map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);

    return layoutView;
  }
示例#13
0
  private void setUpMap() {
    if (this.permissionGranted) {
      try {
        this.mMap.getUiSettings().setMyLocationButtonEnabled(false);
        this.mMap.setMyLocationEnabled(true);
      } catch (SecurityException e) {
        e.printStackTrace();
      }
    }

    try {
      MapsInitializer.initialize(this.getActivity());
    } catch (Exception e) {
      e.printStackTrace();
    }

    // For dropping a marker at a point on the Map

    // For zooming automatically to the Dropped PIN Location
    this.mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(latitude, longitude)));
    this.mMap.animateCamera(
        CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 13.0f));

    this.mapIsInitialised = true;
  }
  public void addHeatMap(List<GridPoint> gridPointList) {
    clearMap();
    List<LatLng> list = new ArrayList<LatLng>();
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    LatLng latLng = null;

    for (GridPoint gridPoint : gridPointList) {
      latLng =
          new LatLng(
              gridPoint.getLocation().getLatitude().doubleValue(),
              gridPoint.getLocation().getLongitude().doubleValue());
      list.add(latLng);
      builder.include(latLng);
    }

    if (list.size() < 1) {
      return;
    }

    mProvider = new HeatmapTileProvider.Builder().data(list).build();
    mOverlay = googleMap.addTileOverlay(new TileOverlayOptions().tileProvider(mProvider));

    if (gridPointList.size() > 1) {
      LatLngBounds bounds = builder.build();
      CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 0);
      googleMap.animateCamera(cu);
    } else if (gridPointList.size() > 0) {
      CameraPosition cameraPosition =
          new CameraPosition.Builder().target(latLng).zoom(zoomLevel).bearing(0).tilt(45).build();
      googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }
    markersDisplayed = false;
    heatmapDisplayed = true;
    clusterDisplayed = false;
  }
  /**
   * This is where we can add markers or lines, add listeners or move the camera. In this case, we
   * just add a marker near Africa.
   *
   * <p>This should only be called once and when we are sure that {@link #mMap} is not null.
   */
  private void setUpMap() {

    // app behavior when the app first starts up
    // centers the map at the SJSU campus
    LatLng SJSU = new LatLng(37.3351874, -121.8810715);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(SJSU, 6));
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(SJSU, 18));

    // Click Listeners

    // Button button4 = (Button) findViewById(R.id.TxButton);
    Button button5 = (Button) findViewById(R.id.clearButton);
    button5.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            // Clear all markers on screen
            mMap.clear();
          }
        });

    // need to work on getting a location value

    // UI settings are added here
    UiSettings uiValue = mMap.getUiSettings();
    uiValue.setZoomControlsEnabled(true);
    uiValue.setMyLocationButtonEnabled(true); // only works if mMap.setLocationEnabled(true)
    uiValue.setCompassEnabled(true); // also doesn't seem to work
  }
示例#16
0
  @Override
  public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setMyLocationEnabled(true);

    Bundle extras = getIntent().getExtras();
    float[] lats = {}, lngs = {};
    String[] titles = {}, snippets = {};
    int[] beers = {};

    if (null != extras) {
      lats = extras.getFloatArray("Latitudes");
      lngs = extras.getFloatArray("Longitudes");
      titles = extras.getStringArray("Titles");
      snippets = extras.getStringArray("Snippets");
      beers = extras.getIntArray("Beers");
    }
    googleMap.setInfoWindowAdapter(new CustomInfoWindowAdapter());

    LatLng ll = null;
    for (int i = 0; i < titles.length; i++) {
      ll = new LatLng(lats[i], lngs[i]);

      MarkerOptions mark = new MarkerOptions().position(ll).title(titles[i]).snippet(snippets[i]);

      // Other color if beer has been drunk.
      // The argument to defaultMarker() takes a float between 0-360.0,
      // check BitmapDescriptorFactory.HUE_*.
      // It is possible to create a BitmapDescriptor from drawables etc.
      BitmapDescriptor icon;
      if (i < beers.length && 0 < beers[i]) {
        icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN);
      } else {
        icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED);
      }
      mark.icon(icon);

      // Add a marker and set the number of beers drunk
      Marker marker = mMap.addMarker(mark);
      beerMap.put(marker, (beers.length > i ? beers[i] : 0));
    }

    /* Add propellern */
    BitmapDrawable bd = (BitmapDrawable) getResources().getDrawable(R.drawable.proppeller);
    Bitmap b = bd.getBitmap();
    Bitmap bhalfsize = Bitmap.createScaledBitmap(b, b.getWidth() / 2, b.getHeight() / 2, false);
    MarkerOptions propellern =
        new MarkerOptions()
            .position(PROPELLERN)
            .icon(BitmapDescriptorFactory.fromBitmap(bhalfsize));
    mMap.addMarker(propellern);

    /* See zoom */
    if (null == ll || 1 < titles.length) {
      // Zoom from far 2.0 (zoomed out) to close 21.0 (zoomed in)
      mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(PROPELLERN, 12.2f));
    } else {
      mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(ll, 12.2f));
    }
  }
示例#17
0
  public void zoomToLocation(Location location, Float zoom, boolean calloutOffset) {
    if (mGoogleMap == null) return;
    // float density = getResources().getDisplayMetrics().density;
    // float targetZoom = zoom > 0 ? zoom : mGoogleMap.getCameraPosition().zoom;
    // double scale = 256 * Math.pow(2, (targetZoom - 1)) / Math.PI;
    // double latitude = location.getLatitude();
    // double longitude = location.getLongitude();

    mGoogleMap.moveCamera(
        CameraUpdateFactory.newLatLngZoom(mGoogleMap.getCameraPosition().target, zoom));
    LatLng dest;
    if (calloutOffset) {
      Point pt =
          mGoogleMap
              .getProjection()
              .toScreenLocation(new LatLng(location.getLatitude(), location.getLongitude()));
      pt.offset(0, getResources().getDimensionPixelSize(R.dimen.callout_offset));
      dest = mGoogleMap.getProjection().fromScreenLocation(pt);
      /*            double y = Math.log(Math.tan(Math.toRadians(latitude) / 2 + Math.PI / 4));
      y += getResources().getDimensionPixelSize(R.dimen.callout_offset) / scale;
      latitude = Math.toDegrees((Math.atan(Math.exp(y)) - Math.PI / 4) * 2);*/
    } else {
      dest = new LatLng(location.getLatitude(), location.getLongitude());
    }
    if (zoom > 0) {
      mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(dest, zoom));
    } else {
      mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(dest));
    }
  }
示例#18
0
  @Override
  public void onLocationChanged(Location location) {
    if (mRefreshLocation) {
      mLocation = location;
      if (mLocation != null) {
        // Bug report: cached GeoPoint is being returned as the first value.
        // Wait for the 2nd value to be returned, which is hopefully not cached?
        ++mLocationCount;
        InfoLogger.geolog(
            "GeoPointMapActivity: "
                + System.currentTimeMillis()
                + " onLocationChanged("
                + mLocationCount
                + ") lat: "
                + mLocation.getLatitude()
                + " long: "
                + mLocation.getLongitude()
                + " acc: "
                + mLocation.getAccuracy());

        if (mLocationCount > 1) {
          mLocationStatus.setText(
              getString(
                  R.string.location_provider_accuracy,
                  mLocation.getProvider(),
                  truncateFloat(mLocation.getAccuracy())));
          mLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
          if (!mZoomed) {
            mZoomed = true;
            mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLatLng, 16));
          } else {
            mMap.animateCamera(CameraUpdateFactory.newLatLng(mLatLng));
          }

          // create a marker on the map or move the existing marker to the
          // new location
          if (mMarker == null) {
            mMarkerOption.position(mLatLng);
            mMarker = mMap.addMarker(mMarkerOption);
            mShowLocation.setClickable(true);
          } else {
            mMarker.setPosition(mLatLng);
          }

          // If location is accurate enough, stop updating position and make the marker draggable
          if (mLocation.getAccuracy() <= mLocationAccuracy) {
            stopGeolocating();
          }
        }

      } else {
        InfoLogger.geolog(
            "GeoPointMapActivity: "
                + System.currentTimeMillis()
                + " onLocationChanged("
                + mLocationCount
                + ") null location");
      }
    }
  }
  @Override
  public void onMapReady(GoogleMap map) {
    //        LatLng Kazik = new LatLng(51.2351792, 22.5469426);
    //        map.addMarker(new MarkerOptions().position(Kazik).title("Klub Kazik"));
    //        map.moveCamera(CameraUpdateFactory.newLatLng(Kazik));
    //
    //        LatLng Silence = new LatLng(51.2464403, 22.5415827);
    //        map.addMarker(new MarkerOptions().position(Silence).title("Klub Silence"));
    //        map.moveCamera(CameraUpdateFactory.newLatLng(Silence));
    //
    //        LatLng Shine = new LatLng(51.2491831, 22.5507555);
    //        map.addMarker(new MarkerOptions().position(Shine).title("Klub Shine"));
    //        map.moveCamera(CameraUpdateFactory.newLatLng(Shine));
    //
    //        LatLng Czekolada = new LatLng(51.2470281, 22.5610082);
    //        map.addMarker(new MarkerOptions().position(Czekolada).title("Klub Czekolada"));
    //        map.moveCamera(CameraUpdateFactory.newLatLng(Czekolada));

    this.map = map;
    LatLng Miejsce = new LatLng(51.2323839, 22.5575203);
    this.map.addMarker(
        new MarkerOptions().position(Miejsce).title(wydarzenie.getMiejsce().getNazwa()));
    this.map.moveCamera(CameraUpdateFactory.newLatLng(Miejsce));
    this.map.moveCamera(CameraUpdateFactory.zoomTo(15));
  }
示例#20
0
 @Override
 public void onLocationChanged(Location location) {
   double latitude = location.getLatitude();
   double longitude = location.getLongitude();
   LatLng latLng = new LatLng(latitude, longitude);
   mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
   mMap.animateCamera(CameraUpdateFactory.zoomTo(15));
 }
 @Override
 public void BuildMap() {
   map = fragment.getMap();
   map.addMarker(
       new MarkerOptions().position(pontoCentralFatec()).title(ConstantsMenus.TITULO_PONTO));
   map.moveCamera(CameraUpdateFactory.newLatLng(pontoCentralFatec()));
   map.animateCamera(CameraUpdateFactory.zoomTo(15));
 }
 private void setUpCurrentPositionPin(LatLng current) {
   mMap.setMapType(MAP_TYPE_NORMAL);
   mMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
   if (current != null) {
     mMap.addMarker(new MarkerOptions().position(current).title(current.toString()));
     mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(current, 20));
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    // Activity sin parte superior
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_plantas_externas);

    gps = new MyLocationListener(this);
    geoCoder = new Geocoder(this);

    mapa =
        ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.fragment)).getMap();
    mapa.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    mapa.setMyLocationEnabled(true);
    // mapa.setOnMapClickListener(this);
    mapa.getUiSettings().setMyLocationButtonEnabled(true);
    mapa.getUiSettings().setCompassEnabled(true);
    mapa.getUiSettings().setZoomControlsEnabled(true);

    mapa.setInfoWindowAdapter(
        new GoogleMap.InfoWindowAdapter() {
          @Override
          public View getInfoWindow(Marker marker) {
            return null;
          }

          @Override
          public View getInfoContents(Marker marker) {

            @SuppressLint("InflateParams")
            View v = getLayoutInflater().inflate(R.layout.map_marker_info_view, null);
            TextView Titulo = (TextView) v.findViewById(R.id.infoWindow_Titulo);
            TextView Description = (TextView) v.findViewById(R.id.infoWindow_descripcion);

            Titulo.setText(marker.getTitle());
            Description.setText(marker.getSnippet());
            return v;
          }
        });
    mapa.setOnMapLoadedCallback(this);
    if (mapa != null) {
      if (mapa.getMyLocation() != null) {
        mapa.moveCamera(
            CameraUpdateFactory.newLatLngZoom(
                new LatLng(mapa.getMyLocation().getLatitude(), mapa.getMyLocation().getLongitude()),
                15));
      } else {
        try {
          mapa.moveCamera(
              CameraUpdateFactory.newLatLngZoom(
                  new LatLng(gps.getLatitude(), gps.getLongitude()), 15));
        } catch (Exception e) {
          Log.e(TAG, e.getMessage());
        }
      }
    }
  }
 public void zoomToExtents(List<LatLng> pointsList) {
   if (!pointsList.isEmpty()) {
     LatLngBounds bounds = getBounds(pointsList);
     CameraUpdate animation;
     if (isMapLayoutFinished()) animation = CameraUpdateFactory.newLatLngBounds(bounds, 30);
     else animation = CameraUpdateFactory.newLatLngBounds(bounds, 480, 360, 30);
     getMap().animateCamera(animation);
   }
 }
示例#25
0
  private void setUpMapIfNeeded() {

    // Do a null check to confirm that we have not already instantiated the map.
    if (norwayMap == null) {
      // Try to obtain the map from the SupportMapFragment.
      norwayMap =
          ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
      // Hide the zoom controls as the button panel will cover it
      norwayMap.getUiSettings().setZoomControlsEnabled(true);

      // Set map type getting configuration from Sharedsettings
      /*MapConfiguration mConf = new MapConfiguration();

      SharedPreferences mapSettings = getSharedPreferences("mapType", 0);
      boolean mTypeNormal = mapSettings.getBoolean("normal", false);
      boolean mTypeSatellite = mapSettings.getBoolean("satellite", false);
      boolean mTypeTerrain = mapSettings.getBoolean("terrain", false);*/

      /*if (mTypeNormal) {
          mMap.setMapType(1);

      }
      if (mTypeSatellite) {
          mMap.setMapType(2);

      }
      if (mTypeTerrain) {
          mMap.setMapType(3);

      }*/

      // Set default camera position and zoom
      LatLng defaultlLatLong = new LatLng(60.8175897, 11.0134724);
      CameraUpdate center = CameraUpdateFactory.newLatLng(defaultlLatLong);
      CameraUpdate zoom = CameraUpdateFactory.zoomTo(5);
      norwayMap.moveCamera(center);
      norwayMap.animateCamera(zoom);

      // Buildings enabled
      norwayMap.setBuildingsEnabled(true);

      // Check if we were successful in obtaining the map.
      if (norwayMap != null) {
        // new ConnectAsync().execute();
        setUpMap("Manolo" + " " + "Holsetgata street", "60.7967395", "11.0735713");
        hairdresserObjects oTest = new hairdresserObjects();
        oTest.setHairdresserName("headZUP");
        oTest.setAddress("Torggata 13");
        oTest.setSchedule("10-22");
        oTest.setEmail("empty");
        oTest.setPhone("62 52 99 88");
        oTest.sethType("Unisex");
        oTest.setFacebookPage("Empty");
        hObjectsList.add(oTest);
      }
    }
  }
示例#26
0
 public MapFragment centerOnLatLng(LatLng latLng, Float zoom) {
   if (latLng != null)
     if (zoom == null) {
       googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
     } else {
       googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));
     }
   return this;
 }
  @Override
  public void onLocationChanged(Location location) {
    mLatitude = location.getLatitude();
    mLongitude = location.getLongitude();
    LatLng latLng = new LatLng(mLatitude, mLongitude);

    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
    mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(12));
  }
示例#28
0
 @Override
 public void onMapReady(GoogleMap map) {
   // On ajoute le marker de l'alert quand la map est dispo
   map.addMarker(
       new MarkerOptions()
           .position(this.currentAlert.getCoord())
           .title(this.currentAlert.getSender() + SPACE + getString(R.string.marker_text)));
   map.moveCamera(CameraUpdateFactory.newLatLng(this.currentAlert.getCoord()));
   map.moveCamera(CameraUpdateFactory.zoomTo(12));
 }
示例#29
0
  private void setMyLocationOnMapWithZoom(Location location) {
    // Creating a LatLng object for the current location
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    // Showing the current location in Google Map
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

    // Zoom in the Google Map
    // Zoom in, animating the camera.
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
  }
示例#30
0
 public void onZoom(View v) {
   // Zoom in function using + button on the UI
   if (v.getId() == R.id.btnZoomIn) {
     mMap.animateCamera(CameraUpdateFactory.zoomIn());
   }
   // Zoom out function using - button on the UI
   if (v.getId() == R.id.btnZoomOut) {
     mMap.animateCamera(CameraUpdateFactory.zoomOut());
   }
 }