Example #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));
    }
  }
Example #2
0
 private static BitmapDescriptor getIcon(Gcp gcp) {
   if (gcp.isMarked) {
     return BitmapDescriptorFactory.fromResource(R.drawable.placemark_circle_red);
   } else {
     return BitmapDescriptorFactory.fromResource(R.drawable.placemark_circle_blue);
   }
 }
Example #3
0
  public void addCreatures(Location location) {
    map.clear();
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    Toast.makeText(this, location.getLatitude() + " " + location.getLongitude(), Toast.LENGTH_SHORT)
        .show();
    double clat = latLng.latitude + 0.05;
    double clng = latLng.longitude + 0.05;
    Toast.makeText(this, clat + " " + clng, Toast.LENGTH_SHORT).show();
    double flat = latLng.latitude - 0.125;
    double flng = latLng.longitude - 0.125;
    Toast.makeText(this, flat + " " + flng, Toast.LENGTH_SHORT).show();
    int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    Random random_spawn = new Random(hour);
    for (int i = 0; i < 2000; i++) {
      double randomLat = (flat) + (random_spawn.nextDouble() * 0.25);
      double randomLng = (flng) + (random_spawn.nextDouble() * 0.25);
      CreatureGenerator creature = new CreatureGenerator(randomLat, randomLng);
      Bitmap b = creature.getBitmap(32);
      map.addMarker(
          new MarkerOptions()
              .position(new LatLng(randomLat, randomLng))
              .title(creature.getName())
              .icon(BitmapDescriptorFactory.fromBitmap(b)));
    }

    CreatureGenerator creature =
        new CreatureGenerator(location.getLatitude() - 0.0005, location.getLongitude() + 0.0005);
    Bitmap b = creature.getBitmap(32);
    map.addMarker(
        new MarkerOptions()
            .position(new LatLng(location.getLatitude() - 0.0005, location.getLongitude() + 0.0005))
            .title(creature.getName())
            .icon(BitmapDescriptorFactory.fromBitmap(b)));
  }
  @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);
    }
  }
  private void addMarkedMarkers() {
    // add marked markers
    // add markets

    markedList = MarkedContent.ITEMS_DISTINCT();
    for (MarkedItem item : markedList) {
      // is the marked add more than once
      int numberOfMarkets = MarkedContent.numberOfMarkets(item.name);
      BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.da_marker_red);
      if (numberOfMarkets <= 1) {
        icon = BitmapDescriptorFactory.fromResource(R.drawable.da_marker_yellow);
      }

      MarkerOptions markerOption =
          new MarkerOptions()
              .position(new LatLng(item.latitude, item.longitude))
              .title(item.name)
              .snippet("klik for at se detaljer")
              .anchor(0.5f, 0.5f)
              .icon(icon);

      Marker marker = googleMap.addMarker(markerOption);

      item.markerId = marker.getId();
    }
  }
Example #6
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 minicurso3 = new LatLng(2.834377, -60.695445);
    LatLng minicurso5 = new LatLng(2.835402, -60.694514);
    LatLng ufrr = new LatLng(2.833946, -60.693431);
    LatLng palestra = new LatLng(2.833998, -60.691348);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(ufrr, 16));
    String text[] = {getString(R.string.pin_minicurso), getString(R.string.pin_palestra)};
    mMap.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pin_azul_azul))
            .position(minicurso3)
            .title(text[0]));
    mMap.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pin_azul_azul))
            .position(minicurso5)
            .title(text[0]));
    mMap.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_pin_verd_azul))
            .position(palestra)
            .title(text[1]));
    mMap.setMyLocationEnabled(true);

    barra.setVisibility(View.GONE);
  }
Example #7
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));
    }
 @Override
 public void onMapReady(GoogleMap googleMap) {
   mGoogleMap = googleMap;
   mGoogleMap.setMyLocationEnabled(true);
   if (mLocation != null) {
     animateToLocation(mLocation);
   }
   if (markerDataMap == null) {
     markerDataMap = new HashMap<>();
     LatLng report = new LatLng(12.9602028, 77.6430893);
     Marker reportMarker =
         googleMap.addMarker(
             new MarkerOptions()
                 .position(report)
                 .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_green)));
     markerDataMap.put(
         reportMarker,
         new MarkerData(
             453235,
             "Broken water pipe",
             "Pipe at indranagar is being broken since 3/Feb/2016",
             "13/feb/2016",
             "3/Feb/2016",
             205));
     report = new LatLng(12.9606028, 77.6460893);
     reportMarker =
         googleMap.addMarker(
             new MarkerOptions()
                 .position(report)
                 .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_red)));
     markerDataMap.put(
         reportMarker,
         new MarkerData(
             658645,
             "Waste Dump",
             "Waste dump at kormangala is pending since 9/Feb/2016",
             "",
             "10/Feb/2016",
             24));
     report = new LatLng(12.9696028, 77.6479893);
     reportMarker =
         googleMap.addMarker(
             new MarkerOptions()
                 .position(report)
                 .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_red)));
     markerDataMap.put(
         reportMarker,
         new MarkerData(
             235234,
             "No Street lights",
             "No street lights at indra nagar. Girls don't feel safe travelling at night. Please help us",
             "",
             "10/Feb/2016",
             14));
     googleMap.setOnMarkerClickListener(this);
   }
 }
Example #9
0
 public BitmapDescriptor getMarkerIcon() {
   BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker);
   if (getType().equals("N")) {
     if (isOpened()) {
       bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_opened);
     } else {
       bitmapDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_closed);
     }
   }
   return bitmapDescriptor;
 }
 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);
   }
 }
Example #11
0
 private void setSrcDistMarker() {
   srcMarker =
       gMap.addMarker(
           new MarkerOptions()
               .position(srcLatLng)
               .title("Starting Point")
               .icon(BitmapDescriptorFactory.fromResource(R.drawable.srcmarker)));
   distMarker =
       gMap.addMarker(
           new MarkerOptions()
               .position(distLatLng)
               .title("Destination Point")
               .icon(BitmapDescriptorFactory.fromResource(R.drawable.distmarker)));
 }
Example #12
0
  /**
   * This is where we can add markers or lines, add listeners or move the camera.
   *
   * <p>This should only be called once and when we are sure that {@link #mMap} is not null.
   */
  private void setUpMap() {

    mapUI = mMap.getUiSettings();
    mapUI.setZoomControlsEnabled(false);

    Intent viewRouteActivity = getIntent();

    this.routeID = Integer.valueOf(viewRouteActivity.getStringExtra("routeID"));
    this.totalDistance = Float.valueOf(viewRouteActivity.getStringExtra("totalDistance"));
    this.avgSpeed = Float.valueOf(viewRouteActivity.getStringExtra("avgSpeed"));
    this.startTime = viewRouteActivity.getStringExtra("startTime");
    this.endtime = viewRouteActivity.getStringExtra("endTime");

    Cursor resultSet = dbHandler.getRoutePoints(this.routeID);

    if (resultSet != null && resultSet.moveToFirst()) {
      PolylineOptions rectOptions = new PolylineOptions().color(Color.BLUE).width(ROUTEWIDTH);

      LatLng routeStart = new LatLng(resultSet.getDouble(LATITUDE), resultSet.getDouble(LONGITUDE));

      LatLng routeEnd = null;

      while (!resultSet.isAfterLast()) {
        rectOptions.add(
            routeEnd = new LatLng(resultSet.getDouble(LATITUDE), resultSet.getDouble(LONGITUDE)));

        resultSet.moveToNext();
      }

      mMap.addPolyline(rectOptions);

      mMap.addMarker(
          new MarkerOptions()
              .position(routeStart)
              .icon(BitmapDescriptorFactory.fromResource(R.drawable.cycling))
              .title(this.startTime));

      mMap.addMarker(
          new MarkerOptions()
              .position(routeEnd)
              .icon(BitmapDescriptorFactory.fromResource(R.drawable.finish))
              .title(this.endtime));

      moveCamera(routeStart, DEFAULTZOOM);

      resultSet.close();
    } else {
      // TODO: some error, no route points for route
    }
  }
Example #13
0
  @Override
  public void onMapReady(GoogleMap map) {
    LatLng dosDeMayo = new LatLng(-12.046374, -77.0427934);
    LatLng bolognesi = new LatLng(-12.06030544, -77.0415616);
    LatLng posRandom1 = new LatLng(-12.02244752, -77.05248356);
    LatLng posRandom2 = new LatLng(-12.01816614, -77.05336332);
    LatLng posReu = new LatLng(-12.02478756, -77.05208659);

    LatLng myPosLL = new LatLng(-12.01712464, -77.05044508);
    // Markers
    // map.addMarker(new MarkerOptions().position(dosDeMayo).title("Pepito"));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16))
            .position(dosDeMayo)
            .title("Fulano"));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16))
            .position(bolognesi)
            .title("Mengano"));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16))
            .position(posRandom2)
            .title("Zutano"));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_user_16))
            .position(posRandom1)
            .title("Perengano"));
    map.addMarker(
        new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_grupo_16))
            .position(posReu)
            .title("Evento 1")
            .snippet("31 de octubre"));
    // Positions
    // map.moveCamera(CameraUpdateFactory.newLatLng(dosDeMayo));
    CameraPosition myPos = new CameraPosition.Builder().target(myPosLL).zoom(14).build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(myPos));

    // Busca mi posición
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    String provider = locationManager.getBestProvider(criteria, true);
    // checkPermission();
    // Fin mi posicion
  }
Example #14
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);
    }
  }
  private MarkerOptions createMarker(ReadableMap markerJson) {
    MarkerOptions options = new MarkerOptions();
    options.position(
        new LatLng(
            markerJson.getMap("coordinates").getDouble("lat"),
            markerJson.getMap("coordinates").getDouble("lng")));

    if (markerJson.hasKey("title")) {
      options.title(markerJson.getString("title"));
    }
    if (markerJson.hasKey("color")) {
      options.icon(BitmapDescriptorFactory.defaultMarker((float) markerJson.getDouble("color")));
    }
    if (markerJson.hasKey("snippet")) {
      options.snippet(markerJson.getString("snippet"));
    }
    if (markerJson.hasKey("icon")) {
      String varName = "";
      ReadableType iconType = markerJson.getType("icon");
      if (iconType.compareTo(ReadableType.Map) >= 0) {
        ReadableMap icon = markerJson.getMap("icon");
        try {
          int resId = getResourceDrawableId(icon.getString("uri"));
          Bitmap image = BitmapFactory.decodeResource(reactContext.getResources(), resId);

          options.icon(
              BitmapDescriptorFactory.fromBitmap(
                  Bitmap.createScaledBitmap(
                      image, icon.getInt("width"), icon.getInt("height"), true)));
        } catch (Exception e) {
          varName = icon.getString("uri");
        }
      } else if (iconType.compareTo(ReadableType.String) >= 0) {
        varName = markerJson.getString("icon");
      }
      if (!varName.equals("")) {
        // Changing marker icon to use resource
        int resourceValue = getResourceDrawableId(varName);
        Log.i(REACT_CLASS, varName + markerJson.toString());
        options.icon(BitmapDescriptorFactory.fromResource(resourceValue));
      }
    }
    if (markerJson.hasKey("anchor")) {
      ReadableArray anchor = markerJson.getArray("anchor");
      options.anchor((float) anchor.getDouble(0), (float) anchor.getDouble(1));
    }
    return options;
  }
Example #16
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);
  }
Example #17
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();
  }
Example #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);
  }
Example #19
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));
 }
  public static Marker placeRobotMarkerOnMap(
      Marker marker,
      GoogleMap mMap,
      LatLng location,
      boolean animateTheCamera,
      Resources res,
      Context context) {
    try {
      marker.remove();
    } catch (Exception e) {
      e.printStackTrace();
      Log.e("MapUtilities", "placeMarkerOnMapUserLatLng: Could not remove Robots Marker");
    }
    MarkerOptions m =
        new MarkerOptions()
            .position(location)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.robot))
            .title("ROBOT");
    marker = mMap.addMarker(m);
    marker.showInfoWindow();
    if (animateTheCamera) animateCameraLatLng(mMap, location, res);

    Log.d("ROBOT_LOCATION", "Latitude: " + location.latitude + " Longitude: " + location.longitude);
    // Toast.makeText(context,"Latitude: " +location.latitude+" Longitude:
    // "+location.longitude,Toast.LENGTH_LONG).show();
    return marker;
  }
Example #21
0
  /** Displays current location with information about timezone etc. */
  private void displayCurrentLocation() {
    final double[] loc = getLocation();
    if (loc == null) {
      Toast.makeText(this, "Could not fetch location", Toast.LENGTH_LONG).show();
      return;
    }

    final View infoWindow = LayoutInflater.from(this).inflate(R.layout.infowindow, null);

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

          @Override
          public View getInfoContents(Marker marker) {
            populateInfoWindow(loc, infoWindow);
            return infoWindow;
          }
        });

    Marker me =
        mMap.addMarker(
            new MarkerOptions()
                .position(new LatLng(loc[0], loc[1]))
                .title("Current Location")
                .icon(BitmapDescriptorFactory.fromResource(android.R.drawable.star_on)));

    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(loc[0], loc[1]), 5));
    me.showInfoWindow();
  }
Example #22
0
  private void setMarkersOptions(Location loc) {

    boolean visible = true;
    if (markersOnMap == null) {
      markersOnMap = new ArrayList<Marker>();
    }

    for (Task task : TaskList.getInstance(getApplicationContext()).getTasks()) {

      LatLng temp = getLatLngIfPossible(task.getLocation());
      if (temp != null) {
        Location tloc = new Location(task.getLocation());
        tloc.setLatitude(temp.latitude);
        tloc.setLongitude(temp.longitude);
        float dist = tloc.distanceTo(loc);

        Marker tempMarker =
            map.addMarker(
                new MarkerOptions()
                    .position(temp)
                    .visible(visible)
                    .title(String.valueOf(task.getTask_id()))
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.marke_65px)));

        if (dist > sbRadOuter.getProgress() * 100) {
          tempMarker.setVisible(false);
        }

        markersOnMap.add(tempMarker);
      }
    }
  }
 @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());
 }
Example #24
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));
    }
  }
Example #25
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) {

    }
  }
 @Override
 protected void onBeforeClusterItemRendered(Case item, MarkerOptions markerOptions) {
   markerOptions
       .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin))
       .title(item.building_name)
       .snippet(item.address);
 }
Example #27
0
  /** Sets the MapView's initial properties. */
  protected void setupMap() {
    gmap.setMapType(GoogleMap.MAP_TYPE_NONE); // Hide Google tiles
    gmap.setMyLocationEnabled(true);

    // Disable UI components
    UiSettings ui = gmap.getUiSettings();
    ui.setAllGesturesEnabled(true);
    ui.setMyLocationButtonEnabled(true);
    ui.setZoomControlsEnabled(false);

    // Add custom map overlay
    overlay =
        gmap.addGroundOverlay(
            new GroundOverlayOptions()
                .image(BitmapDescriptorFactory.fromResource(R.drawable.map_overlay))
                .positionFromBounds(OVERLAY_BOUNDS)
                .zIndex(1.0f));

    gmap.addPolygon(createMapShade()); // Shade out of bounds areas

    gmap.setOnInfoWindowClickListener(this);

    // Center on Lancaster
    centerOnHome();
  }
  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);
  }
    /**
     * Returns an icon for the vehicle that should be shown on the map
     *
     * @param isRealtime true if the marker shown indicate real-time info, false if it should
     *     indicate schedule
     * @param status the vehicles status to add to the map
     * @param response the response which contained the provided status
     * @return an icon for the vehicle that should be shown on the map
     */
    private BitmapDescriptor getVehicleIcon(
        boolean isRealtime, ObaTripStatus status, ObaTripsForRouteResponse response) {
      int colorResource;
      Resources r = Application.get().getResources();

      if (isRealtime) {
        long deviationMin = TimeUnit.SECONDS.toMinutes(status.getScheduleDeviation());
        colorResource = ArrivalInfo.computeColorFromDeviation(deviationMin);
      } else {
        colorResource = R.color.stop_info_scheduled_time;
      }
      int color = r.getColor(colorResource);
      double direction = MathUtils.toDirection(status.getOrientation());
      int halfWind = MathUtils.getHalfWindIndex((float) direction, NUM_DIRECTIONS - 1);
      // Log.d(TAG, "VehicleId=" + status.getVehicleId() + ", orientation= " +
      // status.getOrientation() + ", direction=" + direction + ", halfWind= " + halfWind + ",
      // deviation=" + status.getScheduleDeviation());

      String key = createBitmapCacheKey(halfWind, colorResource);
      Bitmap b = getBitmapFromCache(key);
      if (b == null) {
        // Cache miss - create Bitmap and add to cache
        b = UIUtils.colorBitmap(vehicle_icons[halfWind], color);
        addBitmapToCache(key, b);
      }
      return BitmapDescriptorFactory.fromBitmap(b);
    }
Example #30
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;
  }