Ejemplo n.º 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) {

    }
  }
 private MarkerOptions createMarkerOptions() {
   MarkerOptions options = new MarkerOptions().position(position);
   if (anchorIsSet) options.anchor(anchorX, anchorY);
   if (calloutAnchorIsSet) options.infoWindowAnchor(calloutAnchorX, calloutAnchorY);
   options.title(title);
   options.snippet(snippet);
   options.rotation(rotation);
   options.flat(flat);
   options.icon(getIcon());
   return options;
 }
Ejemplo n.º 3
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);
 }
  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;
  }
    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);
    }
Ejemplo n.º 6
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);
  }
Ejemplo n.º 7
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");
     }
   }
 }
Ejemplo n.º 8
0
    @Override
    public void onLocationChanged(Location location) {
      if (location != null) {
        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE); // 정확도
        criteria.setPowerRequirement(Criteria.POWER_LOW); // 전원 소비량
        criteria.setAltitudeRequired(false); // 고도, 높이 값을 얻어 올지를 결정
        criteria.setBearingRequired(false);
        criteria.setSpeedRequired(false); // 속도
        criteria.setCostAllowed(true); // 위치 정보를 얻어 오는데 들어가는 금전적 비용
        GPSprovider = lm.getBestProvider(criteria, true);

        latitude = location.getLatitude();
        longitude = location.getLongitude();
        LatLng latLng = new LatLng(latitude, longitude);
        MarkerOptions optFirst = new MarkerOptions();
        optFirst.position(latLng); // 위도 • 경도
        optFirst.title("Current Position"); // 제목 미리보기
        optFirst.snippet("Snippet" + ++cnt);
        mMap.addMarker(optFirst).remove();
        mMap.addMarker(optFirst);
      }
    }
Ejemplo n.º 9
0
  @Override
  public void onConnected(Bundle bundle) {
    Location l = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    if (l != null) {
      mCurrentLatLn = new LatLng(l.getLatitude(), l.getLongitude());
      UIUtils.moveCameraTo(mGoogleMap, mCurrentLatLn, this);
    }

    if (mCurrentLatLn != null) {
      final Parish mostClosed = CoreUtils.getMinLatLng(mCurrentLatLn);

      if (mostClosed != null) {
        // Creating MarkerOptions
        MarkerOptions options = new MarkerOptions();

        // Setting the position of the marker
        options.position(mostClosed.getLatLng());
        options.snippet(mostClosed.getDisplayName());
        options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
        mGoogleMap.addMarker(options);

        // Getting URL to the Google Directions API
        String url = getDirectionsUrl(mCurrentLatLn, mostClosed.getLatLng());

        DownloadTask downloadTask = new DownloadTask();

        // Start downloading json data from Google Directions API
        downloadTask.execute(url);
      }
      progressDialog.dismiss();
      showGroup(mCurrentLatLn, mostClosed.getLatLng());

      btnDraw.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              String uri =
                  String.format(
                      Locale.ENGLISH,
                      "http://maps.google.com/maps?saddr=%f,%f(%s)&daddr=%f,%f (%s)",
                      mCurrentLatLn.latitude,
                      mCurrentLatLn.longitude,
                      "My position",
                      mostClosed.getLatLng().latitude,
                      mostClosed.getLatLng().longitude,
                      "" + mostClosed.getDisplayName());
              Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
              intent.setClassName(
                  "com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
              startActivity(intent);
            }
          });
      //            btnDraw.setVisibility(View.VISIBLE);

    } else {
      progressDialog.dismiss();
      Toast.makeText(GoActivity.this, "Please enable your location service.", Toast.LENGTH_SHORT)
          .show();
    }
  }