Esempio n. 1
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;
  }
Esempio n. 2
0
 private void addToMap(Waypoint w) {
   MarkerOptions mo = new MarkerOptions();
   if (w.name != null && w.name.length() > 0) mo.title(w.name);
   if (w.description != null && w.description.length() > 0) mo.snippet(w.description);
   mo.position(new LatLng(w.lat, w.lon));
   mo.icon(BitmapDescriptorFactory.fromResource(R.drawable.pin1));
   // TODO custom icons
   mo.draggable(true);
   Marker m = map.addMarker(mo);
   markers.add(m);
   waypoints.put(m.getId(), w);
 }
Esempio n. 3
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));
  }
    private void showCurrentMap(Double latitude, Double longitude) {
        LatLng curPoint = new LatLng(latitude, longitude);
        map.animateCamera(CameraUpdateFactory.newLatLngZoom(curPoint, 15));

        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);


        MarkerOptions marker = new MarkerOptions();
        marker.position(new LatLng(latitude+0.001, longitude+0.001));
        marker.title("은행 지점");
        marker.snippet("잠실 지점입니다.");
        marker.draggable(true);
        marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.bank));

        map.addMarker(marker);
    }
  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);
  }
  public void addMarkers(List<GridPoint> gridPointList, List<PointEntity> pointEntityList) {
    clearMap();
    Marker m;
    LatLngBounds.Builder builder = new LatLngBounds.Builder();

    for (GridPoint gridPoint : gridPointList) {
      Bitmap icon =
          gridPoint.getScore() > 10
              ? gridPoint.getScore() > 20
                  ? BitmapFactory.decodeResource(getResources(), R.drawable.red_dot)
                  : BitmapFactory.decodeResource(getResources(), R.drawable.yellow_dot)
              : BitmapFactory.decodeResource(getResources(), R.drawable.green_dot);
      float hue =
          gridPoint.getScore() > 10
              ? gridPoint.getScore() > 20
                  ? BitmapDescriptorFactory.HUE_RED
                  : BitmapDescriptorFactory.HUE_YELLOW
              : BitmapDescriptorFactory.HUE_GREEN;

      markerOptions = new MarkerOptions();
      markerOptions.visible(true);
      markerOptions.position(
          new LatLng(
              gridPoint.getLocation().getLatitude().doubleValue(),
              gridPoint.getLocation().getLongitude().doubleValue()));
      markerOptions.draggable(false);
      markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));
      // markerOptions.icon(BitmapDescriptorFactory.defaultMarker(hue));

      m = googleMap.addMarker(markerOptions);
      gridMap.put(m.getId(), gridPoint);
      builder.include(m.getPosition());
    }

    for (PointEntity pointEntity : pointEntityList) {
      Bitmap icon =
          pointEntity.getPointType().equals(PointType.PERSON)
              ? BitmapFactory.decodeResource(getResources(), R.drawable.man)
              : pointEntity.getPointType().equals(PointType.POLICE_STATION)
                  ? BitmapFactory.decodeResource(getResources(), R.drawable.police)
                  : BitmapFactory.decodeResource(getResources(), R.drawable.hospital);
      markerOptions = new MarkerOptions();
      markerOptions.visible(true);
      markerOptions.position(
          new LatLng(
              pointEntity.getLocation().getLatitude().doubleValue(),
              pointEntity.getLocation().getLongitude().doubleValue()));
      markerOptions.draggable(false);
      markerOptions.icon(BitmapDescriptorFactory.fromBitmap(icon));

      m = googleMap.addMarker(markerOptions);
      pointMap.put(m.getId(), pointEntity);
      builder.include(m.getPosition());
    }

    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(
                  new LatLng(
                      gridPointList.get(0).getLocation().getLatitude().doubleValue(),
                      gridPointList.get(0).getLocation().getLongitude().doubleValue()))
              .zoom(zoomLevel)
              .bearing(0)
              .tilt(45)
              .build();
      googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }

    markersDisplayed = true;
    heatmapDisplayed = false;
    clusterDisplayed = false;
  }