@Override
  public void onMapClick(LatLng point) {
    // mTapTextView.setText("tapped, point=" + point);

    int max = markers.size();

    // clear all markers
    for (int j = 0; j < max; j++) {

      marker = markers.get(j);
      marker.setVisible(false);
    }

    for (int i = 0; i < max; i++) {

      polygon = polygons.get(i);

      polygonPath = polygon.getPoints();

      if (PolyUtil.containsLocation(point, polygonPath, false)) {

        // when click change polygon color
        polygon.setFillColor(randomColor());
        marker = markers.get(i);
        marker.setVisible(true);
        marker.showInfoWindow();

        break;
      } // if
    } // for
  }
Esempio n. 2
0
 @Override
 public void onMarkerDrag(Marker marker) {
   if (markers.size() >= 2) {
     polygon.remove();
     // Instantiates a new Polygon object and adds points to define a rectangle
     rectOptions = new PolygonOptions();
     for (Marker mark : markers) {
       rectOptions = rectOptions.add(mark.getPosition());
     }
     polygon.remove();
     // Get back the mutable Polygon
     polygon = map.addPolygon(rectOptions);
   }
 }
Esempio n. 3
0
        @Override
        public void onMapClick(LatLng point) {
          /** We prevents to pu more than the max nb of markers */
          if (markers.size() < nbPoints) {
            Marker marker =
                map.addMarker(
                    new MarkerOptions().position(point).title("Adresse postale").draggable(true));

            markers.add(marker);

            MarkerPos markerpos = new MarkerPos(marker, point);
            getAddress(markerpos);

            if (markers.size() >= 2) {

              // Instantiates a new Polygon object and adds points to define a rectangle
              rectOptions = new PolygonOptions();

              for (Marker mark : markers) {
                rectOptions = rectOptions.add(mark.getPosition());
              }
              // Remove the Polygon if exists
              if (polygon != null) {
                polygon.remove();
              }
              // Get back the mutable Polygon
              polygon = map.addPolygon(rectOptions);
            }
          } else {
            Toast.makeText(
                    getApplicationContext(), "Nombre de points maximum atteint", Toast.LENGTH_SHORT)
                .show();
          }
        }
 private void update_polygon() {
   ArrayList<LatLng> tempLat = new ArrayList<LatLng>();
   for (int i = 0; i < markerArray.size(); i++) {
     LatLng latLng = markerArray.get(i).getPosition();
     tempLat.add(latLng);
   }
   latLngsArray = tempLat;
   polygon.setPoints(tempLat);
 }
  private void readMessage(JsonReader reader) throws IOException {

    String name = null;
    String zone = null;
    String apn = null;
    String address = null;

    reader.beginObject();
    while (reader.hasNext()) {

      tag = reader.nextName();

      if (tag.equals("name")) {
        name = reader.nextString();
      } else if (tag.equals("zone")) {
        zone = reader.nextString();
      } else if (tag.equals("apn")) {
        apn = reader.nextString();
      } else if (tag.equals("address")) {
        address = reader.nextString();
      } else if (tag.equals("feature") && reader.peek() != JsonToken.NULL) {
        polygonPath = readLatLngArray(reader);
      } else {
        reader.skipValue();
      }
    } // while

    reader.endObject();

    // create new marker and polygon
    if (address != null && !address.isEmpty()) {
      address = address + ", COSTA MESA, CA";
    }

    polyopts = new PolygonOptions().addAll(polygonPath);
    polyopts.fillColor(randomColor());
    polyopts.strokeColor(Color.YELLOW);
    polyopts.strokeWidth(1);

    polygon = map.addPolygon(polyopts);

    marker =
        map.addMarker(
            new MarkerOptions()
                .position(polygon.getPoints().get(0))
                .title(address)
                .snippet("APN :[" + apn + "]  Zone : (" + zone + ") ")
                .anchor(0.5f, 0.5f)
                .infoWindowAnchor(0.5f, 0.5f)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.house2)));
    marker.setVisible(false);
  }
Esempio n. 6
0
 private void clearSpouseLine() {
   if (spouseLine != null) spouseLine.remove();
 }