コード例 #1
0
ファイル: SendFragment.java プロジェクト: micsha123/WCMap
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_send, container, false);
    MapView mapView = (MapView) rootView.findViewById(R.id.mapview_send);

    mapView.setCenter(new LatLng(latitude, longitude));
    mapView.setZoom(18);

    Marker customUserMarker = new Marker(mapView, null, null, new LatLng(latitude, longitude));
    customUserMarker.setIcon(new Icon(getActivity(), Icon.Size.LARGE, "post", "9CCC65"));

    mapView.addMarker(customUserMarker);

    buttonFree = (RadioButton) rootView.findViewById(R.id.radioButton_free);
    buttonPaid = (RadioButton) rootView.findViewById(R.id.radioButton_paid);

    editDesc = (EditText) rootView.findViewById(R.id.edit_desc);

    ButtonRectangle buttonSend = (ButtonRectangle) rootView.findViewById(R.id.send_button);

    // old but works on API 10
    buttonSend.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(android.content.Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(android.content.Intent.EXTRA_TEXT, infoToSend());
            startActivity(Intent.createChooser(intent, null));
          }
        });

    return rootView;
  }
コード例 #2
0
        @Override
        public void onShowMarker(MapView mapView, Marker marker) {
          PathOverlay line = new PathOverlay(Color.BLACK, 3);
          markerList.add(marker);
          for (Marker marker1 : markerList) {
            marker1.setIcon(
                new Icon(
                    new BitmapDrawable(
                        getActivity().getResources(),
                        BitmapFactory.decodeResource(
                            getActivity().getResources(), R.drawable.mapmarkerorange))));
            line.addPoint(
                new LatLng(marker1.getPoint().getLatitude(), marker1.getPoint().getLongitude()));
          }
          markerList
              .get(markerList.size() - 1)
              .setIcon(
                  new Icon(
                      new BitmapDrawable(
                          getActivity().getResources(),
                          BitmapFactory.decodeResource(
                              getActivity().getResources(), R.drawable.mapmarkerred))));
          markerList
              .get(0)
              .setIcon(
                  new Icon(
                      new BitmapDrawable(
                          getActivity().getResources(),
                          BitmapFactory.decodeResource(
                              getActivity().getResources(), R.drawable.mapmarkergreen))));

          mapView.getOverlays().add(line);
          lines.add(line);
        }
コード例 #3
0
 @Override
 public void onMarkerDragStart(Marker marker) {
   if (mMarkerDragListener != null) {
     final MarkerInfo markerInfo = mBiMarkersMap.getKey(marker);
     markerInfo.setPosition(DroneHelper.ILatLngToCoord(marker.getPoint()));
     mMarkerDragListener.onMarkerDragStart(markerInfo);
   }
 }
コード例 #4
0
  @Override
  public void updateMarker(MarkerInfo markerInfo, boolean isDraggable) {
    // if the drone hasn't received a gps signal yet
    final Coord2D coord = markerInfo.getPosition();
    if (coord == null) {
      return;
    }

    final LatLng position = DroneHelper.CoordToLatLng(coord);
    Marker marker = mBiMarkersMap.getValue(markerInfo);
    if (marker == null) {
      marker = new Marker(mMapView, markerInfo.getTitle(), markerInfo.getSnippet(), position);
      mMarkersOverlay.addItem(marker);
      mBiMarkersMap.put(markerInfo, marker);
    } else {
      marker.setTitle(markerInfo.getTitle());
      marker.setDescription(markerInfo.getSnippet());
      marker.setPoint(position);
    }

    // Update the marker
    final Resources res = getResources();
    Bitmap markerIcon = markerInfo.getIcon(res);
    if (markerIcon == null) {
      markerIcon = BitmapFactory.decodeResource(res, R.drawable.ic_action_location);
    }

    marker.setIcon(new Icon(new BitmapDrawable(res, markerIcon)));

    marker.setAnchor(new PointF(markerInfo.getAnchorU(), markerInfo.getAnchorV()));
    marker.invalidate();
    mMapView.invalidate();
  }
コード例 #5
0
 public void updateCoordinates() {
   if (mv == null) {
     return;
   }
   // Creating shop location marker
   for (POI poi : POIs) {
     Marker marker =
         new Marker(poi.getName(), poi.getAddress(), new LatLng(poi.getLat(), poi.getLng()));
     marker.setIcon(
         new Icon(
             new BitmapDrawable(
                 getActivity().getResources(),
                 BitmapFactory.decodeResource(
                     getActivity().getResources(), R.drawable.mapmarkerinactive))));
     mv.addMarker(marker);
     mv.setMapViewListener(mapViewListener);
   }
 }
コード例 #6
0
        @Override
        public void onClick(View v) {
          for (Marker marker1 : markerList) {
            marker1.setIcon(
                new Icon(
                    new BitmapDrawable(
                        getActivity().getResources(),
                        BitmapFactory.decodeResource(
                            getActivity().getResources(), R.drawable.mapmarkerinactive))));
          }
          for (PathOverlay line : lines) {
            line.removeAllPoints();
          }

          markerList.clear();
          waypoints.clear();
          // line = new PathOverlay(Color.BLACK, 3);

        }
コード例 #7
0
 @Override
 public void onClick(View v) {
   for (Marker marker1 : markerList) {
     Timber.e("marker " + marker1.getDescription() + " " + marker1.getTitle());
     LatLng lg = marker1.getPoint();
     POI poi =
         new POI(
             marker1.getTitle(),
             marker1.getDescription(),
             lg.getLatitude(),
             lg.getLatitude());
     waypoints.add(poi);
   }
   Intent i = new Intent(getActivity(), TrajetActivity.class);
   Bundle bundle = new Bundle();
   bundle.putSerializable("waypoints", (Serializable) waypoints);
   i.putExtras(bundle);
   startActivity(i);
 }