示例#1
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));
    }
  }
示例#2
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));
    }
示例#3
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);
    }
  }
示例#4
0
  private void addAndMarkGeofenceAdded(LatLng center, int radius) {
    // add geofence
    Geofence geofence =
        new Geofence.Builder()
            .setRequestId(lastGeofence + "")
            .setTransitionTypes(
                Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT)
            .setCircularRegion(center.latitude, center.longitude, radius)
            .setExpirationDuration(Geofence.NEVER_EXPIRE)
            .build();
    lastGeofence++;
    ArrayList<Geofence> geofences = new ArrayList<Geofence>();
    geofences.add(geofence);
    requester.addGeofences(geofences);

    MarkerOptions markerOptions =
        new MarkerOptions()
            .position(center)
            .title("Geofence")
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
    geofenceCenterMarker = map.addMarker(markerOptions);
    CircleOptions circleOptions =
        new CircleOptions()
            .center(geofenceCenter)
            .radius(radius)
            .strokeColor(Color.RED)
            .fillColor(Color.argb(90, 155, 0, 0))
            .strokeWidth(2);
    geofenceCircle = map.addCircle(circleOptions);
  }
示例#5
0
  public GPSTracker(Context context, GoogleMap googleMap, FloatingActionButton focusSelfButton) {
    this.context = context;
    this.mMap = googleMap;
    this.focusSelfButton = focusSelfButton;

    getInitLocation();

    if (latLng != null) {
      mMap.animateCamera(
          CameraUpdateFactory.newCameraPosition(new CameraPosition(latLng, 13, 0, 0)));

      this.marker =
          mMap.addMarker(
              new MarkerOptions()
                  .position(latLng)
                  .title("Current location")
                  .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

      focusSelfButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              mMap.animateCamera(
                  CameraUpdateFactory.newCameraPosition(new CameraPosition(latLng, 13, 0, 0)));
            }
          });

      String[] params = {
        Player.currentPlayer.getGoogleID(), Double.toString(latitude), Double.toString(longitude)
      };
      new EditPlayer().execute(params);
    }
  }
示例#6
0
  @Override
  public void onLocationChanged(Location location) {
    this.latitude = location.getLatitude();
    this.longitude = location.getLongitude();
    this.latLng = new LatLng(latitude, longitude);

    // move marker to new location
    this.marker.remove();
    this.marker =
        this.mMap.addMarker(
            new MarkerOptions()
                .position(latLng)
                .title("Current location")
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

    // reset button to focus on new location
    focusSelfButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            mMap.animateCamera(
                CameraUpdateFactory.newCameraPosition(new CameraPosition(latLng, 13, 0, 0)));
          }
        });

    // update our location in the database
    String[] params = {
      Player.currentPlayer.getGoogleID(), Double.toString(latitude), Double.toString(longitude)
    };
    new EditPlayer().execute(params);
  }
  // Fires when a long press happens on the map
  @Override
  public void onMapLongClick(final LatLng point) {
    //        Toast.makeText(this, "Long Press", Toast.LENGTH_LONG).show();

    if (pinDisplayed) {
      map.clear();
      pinDisplayed = false;
    }

    // Define color of marker icon
    BitmapDescriptor defaultMarker =
        BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED);

    // Creates and adds marker to the map
    Marker marker =
        map.addMarker(
            new MarkerOptions()
                .position(point)
                .title(getResources().getString(R.string.deliver_here))
                .icon(defaultMarker));

    latitude = marker.getPosition().latitude;
    longitude = marker.getPosition().longitude;
    deliveryLocation = getAddress(latitude, longitude);

    pinDisplayed = true;

    dropPinEffect(marker);
  }
 public Marker insertOnMap(GoogleMap map) {
   return map.addMarker(
       new MarkerOptions()
           .title(markerName)
           .position(markerLocation)
           .icon(BitmapDescriptorFactory.defaultMarker(markerColour)));
 }
 @SuppressLint("NewApi")
 private void initilizeMap() {
   try {
     System.out.println("---     initialize Map called    ---" + googleMap);
     if (googleMap == null) {
       mapFragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
       googleMap = mapFragment.getMap();
       googleMap.getUiSettings().setMyLocationButtonEnabled(true);
       googleMap.setMyLocationEnabled(true);
       newlatitude = address.getLatitude();
       newlongitude = address.getLongitude();
       try {
         System.out.println(
             "lat :---------- "
                 + address.getLatitude()
                 + " long :---------- "
                 + address.getLongitude());
         if (address.getLatitude() != 0.0 && address.getLongitude() != 0.0) {
           googleMap.addMarker(
               new MarkerOptions()
                   .position(new LatLng(address.getLatitude(), address.getLongitude()))
                   .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
         }
         ViewGroup.LayoutParams params = mapFragment.getView().getLayoutParams();
         mapFragment.getView().setLayoutParams(params);
         googleMap.animateCamera(
             CameraUpdateFactory.newLatLngZoom(
                 new LatLng(address.getLatitude(), address.getLongitude()), 13.0f));
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   } finally {
   }
 }
  public void play() {

    // Hide the finish button
    finishButton.setVisibility(View.INVISIBLE);

    // Changes the text and the colour of the button
    startButton.setText("Pause");
    startButton.getBackground().setColorFilter(Color.YELLOW, PorterDuff.Mode.MULTIPLY);

    // Resume time count from previous time.
    myChrono.setBase(SystemClock.elapsedRealtime() + timeWhenPaused);
    myChrono.start();

    // Only drop a green marker at the beginning of the activity
    if (firstTime == true) {

      // Drop Green marker at start position
      map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
      LatLng startLocation = new LatLng(latitude, longitude);
      routePoints.add(startLocation);
      polyline.add(startLocation);
      CameraUpdate update = CameraUpdateFactory.newLatLngZoom(startLocation, 17);
      map.addMarker(
          new MarkerOptions()
              .position(startLocation)
              .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
      map.animateCamera(update);
      firstTime = false;
    }
  }
  public void pause() {

    // Show the finish button
    finishButton.setVisibility(View.VISIBLE);

    // Changes the text and the colour of the button
    startButton.setText("Resume");
    startButton.getBackground().setColorFilter(Color.GREEN, PorterDuff.Mode.MULTIPLY);

    // Save the current time
    timeWhenPaused = myChrono.getBase() - SystemClock.elapsedRealtime();
    myChrono.stop();

    // Set a yellow marker on the current paused location
    LatLng pauseLocation = new LatLng(latitude, longitude);
    map.addMarker(
        new MarkerOptions()
            .position(pauseLocation)
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)));

    // Zoom out to fit route points on the map.
    // This shows the user the total distance travelled on the map
    int last = routePoints.size();
    if (last >= 2) {

      LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
      for (int i = 0; i < last; i++) {
        boundsBuilder.include(routePoints.get(i));
      }

      LatLngBounds bounds = boundsBuilder.build();
      map.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 180));
    } else ;
  }
示例#12
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;
    }
  }
    @Override
    protected void onPostExecute(List<EarthQuakeRec> result) {

      // Get Map Object
      mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

      if (null != mMap) {

        // Add a marker for every earthquake

        for (EarthQuakeRec rec : result) {

          // Add a new marker for this earthquake
          mMap.addMarker(
              new MarkerOptions()

                  // Set the Marker's position
                  .position(new LatLng(rec.getLat(), rec.getLng()))

                  // Set the title of the Marker's information window
                  .title(String.valueOf(rec.getMagnitude()))

                  // Set the color for the Marker
                  .icon(BitmapDescriptorFactory.defaultMarker(getMarkerColor(rec.getMagnitude()))));
        }

        // Center the map
        // Should compute map center from the actual data

        mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(CAMERA_LAT, CAMERA_LNG)));
      }

      if (null != mClient) mClient.close();
    }
  private void setUpMap() {
    verifyLocationPermission();

    mMap.setOnMapClickListener(this);
    mMap.setOnInfoWindowClickListener(this);

    UiSettings settings = mMap.getUiSettings();
    settings.setAllGesturesEnabled(true);
    settings.setMapToolbarEnabled(false);

    // Use stops location if present, otherwise set a geo point in
    // central Stockholm.
    LatLng latLng;
    int zoom;
    if (mStop.getLocation() != null) {
      latLng = new LatLng(mStop.getLocation().getLatitude(), mStop.getLocation().getLongitude());
      zoom = 16;
    } else {
      latLng = new LatLng(59.325309, 18.069763);
      zoom = 12;
    }

    mMarker =
        mMap.addMarker(
            new MarkerOptions()
                .position(latLng)
                .title(getString(R.string.tap_to_select_this_point))
                .visible(true)
                .draggable(true)
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));
    mMarker.showInfoWindow();

    mMap.moveCamera(
        CameraUpdateFactory.newCameraPosition(CameraPosition.fromLatLngZoom(latLng, zoom)));
  }
示例#15
0
  /** ****** Get A route Between source & destination ****** */
  private void getRoute(LatLng srcLatLng, LatLng distLatLng) {
    final RouteDrawer routeDrawer =
        new RouteDrawer.RouteDrawerBuilder(gMap)
            .withColor(Color.BLUE)
            .withWidth(5)
            .withAlpha(0.0f)
            .withMarkerIcon(
                BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW))
            .build();

    RouteRest routeRest = new RouteRest();
    routeRest
        .getJsonDirections(srcLatLng, distLatLng, TravelMode.DRIVING)
        .observeOn(AndroidSchedulers.mainThread())
        .map(
            new Func1<String, Routes>() {
              @Override
              public Routes call(String s) {
                return new RouteJsonParser<Routes>().parse(s, Routes.class);
              }
            })
        .subscribe(
            new Action1<Routes>() {
              @Override
              public void call(Routes r) {
                routeDrawer.drawPath(r);
              }
            });
  }
示例#16
0
 public void mileMarker(objData objDataList, String Title) {
   map.addMarker(
       new MarkerOptions()
           .position(new LatLng(objDataList.lat, objDataList.lng))
           .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
           .title(Title));
 }
示例#17
0
  // Populates the waypoints ArrayList with the route waypoints, each with its relative distance
  // from the destination
  private void analyzeRoute(ArrayList<LatLng> route) {
    if (route == null) route = this.route;
    double runningDistance = 0;
    if (waypoints == null) waypoints = new Stack<>();

    ArrayList<LatLng> reverseRoute = new ArrayList<>();
    reverseRoute.addAll(route);
    Collections.reverse(reverseRoute);

    LatLng previousWaypoint = new LatLng(0, 0);
    Iterator<LatLng> it = reverseRoute.iterator();
    if (it.hasNext()) previousWaypoint = it.next();

    mMap.addMarker(
        new MarkerOptions()
            .position(previousWaypoint)
            .title("Destination")
            .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));

    while (it.hasNext()) {
      LatLng waypoint = it.next();
      double distance = directionsHelper.getDistanceInMeters(waypoint, previousWaypoint);
      runningDistance += distance;
      previousWaypoint = waypoint;
      waypoints.push(new Waypoint(waypoint.latitude, waypoint.longitude, runningDistance));
    }
  }
示例#18
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);
  }
示例#19
0
  private void initializeMapElements() {
    double lat = currentLocation.getLatitude();
    double lon = currentLocation.getLongitude();
    myLatLng = new LatLng(lat, lon);

    // Set initial values for map variables
    zoomLevel = 15;
    pathLineWidth = 15;

    // Add marker
    myMarker =
        mMap.addMarker(
            new MarkerOptions()
                .position(myLatLng)
                .title("Origin")
                .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE)));

    // Move camera to current location
    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(myLatLng, zoomLevel));
    mMap.setOnCameraChangeListener(
        new GoogleMap.OnCameraChangeListener() {
          @Override
          public void onCameraChange(CameraPosition position) {
            zoomLevel = position.zoom;
          }
        });

    mapInitialized = true;
  }
示例#20
0
  /**
   * pointsに地点を追加するためのメソッド。追加する前に、パラメータのMarkerOptions (mo) が円に
   * 入っているかどうかに基づいて地点の色が変化。後、moと中心地点の距離がmoのsnippitに表示される。
   * もし、ユーザーが中心地点が表示される前に地点を追加すると、snippitはアップデートされません。
   *
   * @param mo 追加する地点
   * @param context 現在のコンテクスト
   */
  public static void addPoint(MarkerOptions mo, Context context) {
    MarkerOptions temp = mo;
    LatLng centerPtPos = centerPoint.getPosition();

    // 追加する地点の色を決める
    if (calculationByDistance(mo.getPosition(), centerPtPos) < circleRadius)
      temp.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
    else temp.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));

    if (centerPoint.isVisible()) {
      double dtc =
          (double) Math.round(calculationByDistance(mo.getPosition(), centerPtPos) * 100000)
              / 100000;
      temp.snippet(context.getString(R.string.dist_to_center) + ": " + String.valueOf(dtc) + " km");
    }
    points.add(0, temp);
  }
 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);
 }
示例#22
0
 /**
  * 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(double lat, double lng, String tittle, float color) {
   MarkerOptions marker =
       new MarkerOptions()
           .title(tittle)
           .position(new LatLng(lat, lng))
           .icon(BitmapDescriptorFactory.defaultMarker(color));
   mMap.addMarker(marker);
 }
    // 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;
    }
示例#24
0
 private void marcadorGrande(LatLng position, String titulo, String info) {
   Marker myMaker =
       mMap.addMarker(
           new MarkerOptions()
               .position(position)
               .title(titulo)
               .snippet(info)
               .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE)));
 }
示例#25
0
 /**
  * 自動的に全ての地点の色とSnippitを変えるためのメソッド
  *
  * @param context 現在のコンテクスト
  */
 public static void updatePointColors(Context context) {
   for (MarkerOptions m : points) {
     if (calculationByDistance(m.getPosition(), centerPoint.getPosition()) < circleRadius)
       m.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
     else m.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
     if (centerPoint.isVisible()) {
       double distToCenter =
           (double)
                   Math.round(
                       calculationByDistance(m.getPosition(), centerPoint.getPosition()) * 100000)
               / 100000;
       m.snippet(
           context.getString(R.string.dist_to_center)
               + ": "
               + String.valueOf(distToCenter)
               + " km");
     }
   }
 }
示例#26
0
 private void addMarker(Shelf shelf, int faceNum) {
   // Add a marker to mark where product is
   float rot = 90f * shelf.faces.get(faceNum).orientation;
   mMap.addMarker(
       new MarkerOptions()
           .position(shelf.pos)
           .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
           .rotation(rot)
           .flat(true)
           .visible(true));
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   MapsInitializer.initialize(getApplicationContext());
   markcol =
       new BitmapDescriptor[] {
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ORANGE),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_VIOLET),
         BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)
       };
   setContentView(R.layout.activity_maps);
   setUpMapIfNeeded();
 }
  private void addMarker(double latitude, double longitude, double percent) {
    // create marker
    MarkerOptions marker =
        new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps");

    if (percent > 90) {
      // Changing marker icon
      marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
      vertices.add(new Vertex(latitude, longitude));
    } else if (percent > 50)
      // Changing marker icon
      marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
    else {
      // Changing marker icon
      marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
    }

    // adding marker
    googleMap.addMarker(marker);
  }
示例#29
0
 private void marcadorCultural(LatLng position, String titulo, String info) {
   // Agregamos marcadores para indicar sitios de interéses.
   Marker myMaker =
       mMap.addMarker(
           new MarkerOptions()
               .position(position)
               .title(titulo) // Agrega un titulo al marcador
               .snippet(info) // Agrega información detalle relacionada con el marcador
               .icon(
                   BitmapDescriptorFactory.defaultMarker(
                       BitmapDescriptorFactory.HUE_GREEN))); // Color del marcador
 }
 private BitmapDescriptor getIcon() {
   if (hasCustomMarkerView) {
     // creating a bitmap from an arbitrary view
     return BitmapDescriptorFactory.fromBitmap(createDrawable());
   } else if (iconResourceId != null) {
     // use local image as a marker
     return BitmapDescriptorFactory.fromResource(iconResourceId);
   } else {
     // render the default marker pin
     return BitmapDescriptorFactory.defaultMarker(this.markerHue);
   }
 }