Пример #1
0
  public void addMaker(Clinic clinic) {
    BitmapDescriptor icon = null;

    try {
      icon = BitmapDescriptorFactory.fromResource(R.drawable.s7apoint);
    } catch (Exception exception) {
    }

    try {
      double latitude = Double.parseDouble(clinic.latitude);
      double longitude = Double.parseDouble(clinic.longitude);
      LatLng mLocation = new LatLng(latitude, longitude);
      GoogleMap googleMap = getMap();
      MarkerOptions myMarkerOptions = new MarkerOptions();
      myMarkerOptions.position(mLocation);
      myMarkerOptions.title(clinic.name);
      myMarkerOptions.snippet(clinic.address);
      if (icon != null) {
        myMarkerOptions.icon(icon);
      }

      com.google.android.gms.maps.model.Marker marker = googleMap.addMarker(myMarkerOptions);
    } catch (Exception exception) {

    }
  }
Пример #2
0
 private MarkerOptions getMarkerOption(LatLng coordinate, String stationName) {
   MarkerOptions markerOptions = new MarkerOptions();
   markerOptions.position(coordinate);
   markerOptions.title(stationName);
   markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.train));
   return markerOptions;
 }
  private void showLocations(Cursor c) {

    MarkerOptions markerOptions = null;
    LatLng position = null;
    mMap.clear();
    while (c.moveToNext()) {
      markerOptions = new MarkerOptions();
      position = new LatLng(Double.parseDouble(c.getString(1)), Double.parseDouble(c.getString(2)));

      // Coordenadas seleccionadas
      localizacionVO = new WS_LocalizacionVO();
      localizacionVO.setLatitudeLoc(position.latitude);
      localizacionVO.setLongitudeLoc(position.longitude);
      modifico = true;

      markerOptions.position(position);
      markerOptions.title(c.getString(0));
      markerSelect = mMap.addMarker(markerOptions);
    }
    if (position != null) {
      CameraUpdate cameraPosition = CameraUpdateFactory.newLatLngZoom(position, 15);

      mMap.animateCamera(cameraPosition);
    }
  }
  public void customAddMarker(LatLng latLng, String title, String snippet) {
    MarkerOptions options = new MarkerOptions();
    options.position(latLng).title(title).snippet(snippet).draggable(false);
    options.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin));

    marker = map.addMarker(options);
  }
Пример #5
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));
    }
  }
Пример #6
0
  @Override
  public void resultListLugares(Boolean exito, List<Lugar> lugares) {
    if (exito == true) {

      MarkerOptions markerLugaresOption = new MarkerOptions();
      LatLng latitudLongitud;

      String nameLugar, direccionLugar;
      double latitud, longitud;

      for (int i = 0; i < lugares.size(); i++) {

        nameLugar = lugares.get(i).getNombre();
        direccionLugar = lugares.get(i).getDireccion();
        latitud = lugares.get(i).getUbicacion().getLatitude();
        longitud = lugares.get(i).getUbicacion().getLongitude();

        latitudLongitud = new LatLng(latitud, longitud);
        markerLugaresOption.position(latitudLongitud);
        markerLugaresOption.title(nameLugar + " " + direccionLugar);

        mMap.addMarker(markerLugaresOption);
      }
    } else {
      Toast.makeText(context, "ERROR CARGANDO LUGARES", Toast.LENGTH_SHORT).show();
    }
  }
Пример #7
0
  // 在地圖加入指定位置與標題的標記
  private void addMarker(LatLng place, String title, String context) {
    BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher);

    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(place).title(title).snippet(context).icon(icon);

    mMap.addMarker(markerOptions);
  }
 private void markWaypoint(LatLng point) {
   // Create MarkerOptions object
   MarkerOptions markerOptions = new MarkerOptions();
   markerOptions.position(point);
   markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
   Marker marker = aMap.addMarker(markerOptions);
   mMarkers.put(mMarkers.size(), marker);
 }
Пример #9
0
 /** @return 円の中の地点のArrayList */
 public static ArrayList<MarkerOptions> getInsidePoints() {
   ArrayList<MarkerOptions> insidePoints = new ArrayList<MarkerOptions>();
   for (MarkerOptions m : points) {
     if (calculationByDistance(m.getPosition(), centerPoint.getPosition()) < circleRadius)
       insidePoints.add(m);
   }
   return insidePoints;
 }
Пример #10
0
    // Executed after the complete execution of doInBackground() method
    @Override
    protected void onPostExecute(List<HashMap<String, String>> list) {

      // Clears all the existing markers
      mGoogleMap.clear();

      for (int i = 0; i < list.size(); i++) {

        // Creating a marker
        MarkerOptions markerOptions = new MarkerOptions();

        // Getting a place from the places list
        HashMap<String, String> hmPlace = list.get(i);

        // Getting latitude of the place
        double lat = Double.parseDouble(hmPlace.get("lat"));

        // Getting longitude of the place
        double lng = Double.parseDouble(hmPlace.get("lng"));

        // Getting name
        String name = hmPlace.get("place_name");

        // Getting vicinity
        String vicinity = hmPlace.get("vicinity");

        // Getting the type
        String type = hmPlace.get("type");

        // Getting the price_level
        String price = hmPlace.get("price");
        int price_level = Integer.parseInt(price);
        int user_price = Integer.parseInt(price);
        LatLng latLng = new LatLng(lat, lng);

        // Setting the position for the marker
        markerOptions.position(latLng);

        // Setting the title for the marker.
        // This will be displayed on taping the marker
        markerOptions.title(name + " : " + vicinity);

        if (price_level <= user_price) {
          // Placing a marker on the touched position
          if (theRandomPlace != null && !theRandomPlace.equals(name)) {
            markerOptions.icon(
                BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
          }
          Marker marker = mGoogleMap.addMarker(markerOptions);
          String id = marker.getId();
          placeArray.add(name);
          addressArray.add(vicinity);
          locationArray.add(latLng);
          idArray.add(id);
        }
      }
      done_loading = true;
    }
Пример #11
0
  /**
   * Places a marker on the map.
   *
   * @param markable the markable object
   */
  public Marker addMarkable(Markable markable) {
    MarkerOptions opt = new MarkerOptions();
    markable.mark(opt); // Allow object to adjust marker

    Log.v(
        TAG,
        String.format("Adding marker: pos = %s, title = %s", opt.getPosition(), opt.getTitle()));
    return gmap.addMarker(opt);
  }
Пример #12
0
  public MarkerOptions createMarker(Alert alert) {

    MarkerOptions options = new MarkerOptions();
    options.position(locationToLatLngConverter.convert((alert.getLocation())));
    options.draggable(false);
    options.title(alert.getName());

    return options;
  }
Пример #13
0
  @Override
  public void onResume() {
    super.onResume();
    MarkerOptions options;

    GoogleMap map = getMap();
    map.setOnMarkerClickListener(this);
    map.setMyLocationEnabled(true);
    map.setOnInfoWindowClickListener(this);

    for (Mappable item : mList) {
      options = new MarkerOptions();
      if (mDetailer != null) {
        mDetailer.fillMarker(item, options);

      } else {
        options
            .position(toLatLng(item))
            .title(
                Double.toString(item.getMapLatitude())
                    + ", "
                    + Double.toString(item.getMapLongitude()))
            .draggable(false);
      }
      // options.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin_large));
      map.addMarker(options);
    }

    if (mList.size() == 0) {
      throw new IllegalStateException("Has no point to view");

    } else if (mList.size() == 1) {
      CameraUpdate update = CameraUpdateFactory.newLatLngZoom(toLatLng(mList.get(0)), 16); // MAGIC
      map.moveCamera(update);

    } else {
      map.setOnCameraChangeListener(
          new OnCameraChangeListener() {

            @Override
            public void onCameraChange(CameraPosition arg0) {
              GoogleMap map = getMap();
              LatLngBounds.Builder builder = LatLngBounds.builder();

              for (Mappable point : mList) {
                builder.include(toLatLng(point));
              }

              CameraUpdate update = CameraUpdateFactory.newLatLngBounds(builder.build(), 20);
              map.moveCamera(update);

              map.setOnCameraChangeListener(null);
            }
          });
    }
  }
Пример #14
0
  /** ��ʼ��һЩdemo�� */
  private void initDemoPoint() {
    final LatLng ll = new LatLng(37.339085, -121.8914807);
    MarkerOptions mo = new MarkerOptions();
    mo.position(ll);
    map.addMarker(mo);

    // move to marker position.
    CameraUpdate cu = CameraUpdateFactory.newLatLng(ll);
    map.animateCamera(cu);
  }
Пример #15
0
  @Override
  public void chooseMarker(final MarkerOptions markerOptions, final ClusterPoint clusterPoint) {
    final Equipement bicloo = (Equipement) clusterPoint.getPointAtOffset(0).getTag();
    final BitmapDescriptor icon =
        BitmapDescriptorFactory.fromResource(Equipement.Type.TYPE_BICLOO.getMapPin());
    final String title = bicloo.getNom();

    markerOptions.icon(icon);
    markerOptions.title(title);
  }
Пример #16
0
  private void drawMarker(LatLng point) {
    // Creating an instance of MarkerOptions
    MarkerOptions markerOptions = new MarkerOptions();

    // Setting latitude and longitude for the marker
    markerOptions.position(point);

    // Adding marker on the Google Map
    map.addMarker(markerOptions);
  }
Пример #17
0
  /**
   * Manipulates the map once available. This callback is triggered when the map is ready to be
   * used. This is where we can add markers or lines, add listeners or move the camera. In this
   * case, we just add a marker near Sydney, Australia. If Google Play services is not installed on
   * the device, the user will be prompted to install it inside the SupportMapFragment. This method
   * will only be triggered once the user has installed Google Play services and returned to the
   * app.
   */
  @Override
  public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // Add a marker in Sydney and move the camera
    LatLng atlanta = new LatLng(33.761926, -84.371177);
    MarkerOptions myMarker = new MarkerOptions().position(atlanta).title("Marker in Atlanta");
    myMarker.draggable(true);
    mMap.addMarker(myMarker);
    // newLatLngBounds(latlng, 10)
    // newLatLng(atlanta)
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(atlanta, 10));
  }
  public void addMarker(Airplane airplane) {
    AirplanePosition position = airplane.getLastPosition();
    LatLng location = new LatLng(position.getLatitude(), position.getLongitude());
    float angle = (float) airplane.getHead() - map.getCameraPosition().bearing;

    MarkerOptions options = new MarkerOptions();
    options.position(location);
    options.title(airplane.getHex());
    options.icon(BitmapDescriptorFactory.fromBitmap(getAirplaneIcon(angle)));
    options.anchor(0.5f, 0.5f);

    Marker marker = map.addMarker(options);
    markers.add(marker);
  }
  @Override
  public void updateLocationMarker(Location location) {
    if (locationChangedListener != null) {
      currentUserLocation = location;
      locationChangedListener.onLocationChanged(location);
    }

    // Update clickable area
    LatLng userPosition = getUserLocation(location);
    if (userPositionClickArea == null) {
      MarkerOptions markerOptions = new MarkerOptions();
      markerOptions.position(userPosition);
      markerOptions.anchor(0.4f, 0.4f); // strange google maps bug
      markerOptions.icon(BitmapDescriptorFactory.fromBitmap(clickableBitmap));
      userPositionClickArea = googleMap.addMarker(markerOptions);
    } else {
      userPositionClickArea.setPosition(userPosition);
    }
    if (userPositionClickArea2 == null) {
      MarkerOptions markerOptions = new MarkerOptions();
      markerOptions.position(userPosition);
      markerOptions.anchor(0.6f, 0.6f); // strange google maps bug
      markerOptions.icon(BitmapDescriptorFactory.fromBitmap(clickableBitmap));
      userPositionClickArea2 = googleMap.addMarker(markerOptions);
    } else {
      userPositionClickArea2.setPosition(userPosition);
    }
  }
Пример #20
0
    @Override
    protected void onPostExecute(List<Address> addresses) {

      if (addresses == null || addresses.size() == 0) {
        Toast.makeText(getBaseContext(), "No Location found", Toast.LENGTH_SHORT).show();
        setProgressBarIndeterminateVisibility(false);

        return;
      }

      ViewMapFragment mMapFragment =
          (ViewMapFragment) getSupportFragmentManager().findFragmentByTag("map");

      if (!searchMarkers.isEmpty()) {
        // Clears all the existing markers on the map
        for (Marker m : searchMarkers) {
          m.remove();
        }
        searchMarkers.clear();
      }

      // Adding Markers on Google Map for each matching address
      for (int i = 0; i < addresses.size(); i++) {

        Address address = (Address) addresses.get(i);

        // Creating an instance of GeoPoint, to display in Google Map
        LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());

        String addressText =
            String.format(
                "%s, %s",
                address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "",
                address.getCountryName());

        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(latLng);
        markerOptions.title(addressText);
        markerOptions.icon(
            BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));

        searchMarkers.add(mMapFragment.mMap.addMarker(markerOptions));

        // Locate the first location
        if (i == 0) mMapFragment.mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
      }
      querying = false;
      setProgressBarIndeterminateVisibility(false);
    }
Пример #21
0
    @Override
    protected void onPostExecute(String result) {
      Log.d("TAG", "Download task onpost");
      JSONObject jObject;
      ArrayList<ArrayList<String>> plan = new ArrayList<>();
      ArrayList<ArrayList<String>> step_dis = new ArrayList<>();
      ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

      Log.d("TAG", "switch mode=" + mode);
      try {
        map.clear();
        jObject = new JSONObject(result);
        RoutesTextJSONParser par = new RoutesTextJSONParser();
        summary = par.parse(jObject, "SUMMARY");
        sep_distance = par.parse(jObject, "PLACE_NAVI_DISTANCE"); // in meters
        sep_duration = par.parse(jObject, "PLACE_NAVI_DURATION"); // in seconds

        Log.d("TAG", "Size of summary" + String.valueOf(summary.size()));
        Log.d("TAG", "Size of sep_dis" + String.valueOf(sep_distance.size()));
        Log.d("TAG", "Size of sep_dur" + String.valueOf(sep_duration.size()));
        for (int i = 0; i < summary.size(); i++) {
          Log.d("TAG", "summary=" + summary.get(i));
          Log.d("TAG", "sep_dis=" + sep_distance.get(i));
          Log.d("TAG", "sep_dur=" + sep_duration.get(i));
        }

        // parse 出文字指示路段
        plan = par.parseroad(jObject, 0, "PLACE_NAVI_TEXT");
        Log.d("TAG", "PLACE_NAVI_TEXT size:" + plan.size());

        // parse出每一個step的distance
        step_dis = par.parseroad(jObject, 0, "PLACE_NAVI_STEPS_DIS");
        Log.d("TAG", "step_dis size:" + step_dis.size());

        bindtext(plan, step_dis);
        getMap(result);

        MarkerOptions dest_options = new MarkerOptions();
        dest_options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
        dest_options.position(XY);
        dest_options.title("終點:" + ret_place_Name.get(0));
        map.addMarker(dest_options);
        Log.d("TAG", "marker");

        if (loc_marker != null) {
          loc_marker.remove();
        }
        MarkerOptions pos_options = new MarkerOptions();
        pos_options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
        pos_options.position(pos);
        pos_options.title("目前位置");
        loc_marker = map.addMarker(pos_options);

      } catch (Exception e) {
        e.printStackTrace();
      }
      sum.setText(summary.get(0));
      dis_dur.setText(sep_distance.get(0) + "/" + sep_duration.get(0));
    }
Пример #22
0
  private void drawStartEndMarkers() {
    for (int i = 0; i < markerPoints.size(); i++) {
      MarkerOptions opt = new MarkerOptions();
      opt.position(markerPoints.get(i));

      if (i == 0) {
        opt.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
      } else if (i == 1) {
        opt.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
      }

      // Add new marker to the Google Map Android API V2
      map.addMarker(opt);
    }
  }
Пример #23
0
 @Override
 public void onMapLongClick(LatLng latlng) {
   // 既に追加マーカーを配置済みなら、前のマーカーを削除する
   if (mAddMarker != null) {
     mAddMarker.remove();
     mAddMarker = null;
   }
   // マーカーを追加し、インフォウィンドウを表示する
   MarkerOptions options = new MarkerOptions();
   options.position(latlng);
   BitmapDescriptor icon = BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE);
   options.icon(icon);
   options.title(getString(R.string.Marker_NotRegistered));
   mAddMarker = mMap.addMarker(options);
   mAddMarker.showInfoWindow();
 }
 @Override
 protected void onBeforeClusterItemRendered(Case item, MarkerOptions markerOptions) {
   markerOptions
       .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin))
       .title(item.building_name)
       .snippet(item.address);
 }
Пример #25
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");
      }
    }
  }
Пример #26
0
 @Override
 protected void onBeforeClusterItemRendered(MarkerData item, MarkerOptions markerOptions) {
   super.onBeforeClusterItemRendered(item, markerOptions);
   imageView.setImageResource(item.getProfilePhoto());
   Bitmap icon = iconGenerator.makeIcon();
   markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon)).title(item.getName());
 }
  public void updateMarkerLocation(double lat, double lng) {
    LatLng location = new LatLng(lat, lng);

    if (marker == null) {
      markerOptions = new MarkerOptions();
      markerOptions.visible(true);
      markerOptions.position(location);
      markerOptions.draggable(draggable);
      marker = googleMap.addMarker(markerOptions);
    }

    CameraPosition cameraPosition =
        new CameraPosition.Builder().target(location).zoom(zoomLevel).bearing(0).tilt(45).build();
    googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    marker.setPosition(location);
  }
Пример #28
0
 @Override
 protected void onBeforeClusterItemRendered(HostBriefInfo host, MarkerOptions markerOptions) {
   String street = host.getStreet();
   String snippet = host.getCity() + ", " + host.getProvince().toUpperCase();
   if (street != null && street.length() > 0) {
     snippet = street + "<br/>" + snippet;
   }
   if (mLastDeviceLocation != null) {
     double distance =
         Tools.calculateDistanceBetween(host.getLatLng(), mLastDeviceLocation, mDistanceUnit);
     snippet +=
         "<br/>" + getString(R.string.distance_from_current, (int) distance, mDistanceUnit);
   }
   markerOptions.title(host.getFullname()).snippet(snippet);
   markerOptions.icon(mSingleHostBitmapDescriptor);
 }
Пример #29
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;
    }
  }
Пример #30
0
  public void ShowMarker(
      Double LocationLat, Double LocationLong, String LocationName, Integer LocationIcon) {
    LatLng Coord = new LatLng(LocationLat, LocationLong);

    if (map != null) {
      map.setMyLocationEnabled(true);
      map.moveCamera(CameraUpdateFactory.newLatLngZoom(Coord, 5));

      MarkerOptions abc = new MarkerOptions();
      MarkerOptions x =
          abc.title(LocationName)
              .position(Coord)
              .icon(BitmapDescriptorFactory.fromResource(LocationIcon));
      map.addMarker(x);
    }
  }