Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.form_mapview);

    mapView = (AdvancedMapView) findViewById(R.id.advancedMapView);

    ImageButton buttonLocation = (ImageButton) findViewById(R.id.ButtonLocation);

    // mapView = new AdvancedMapView(this);

    initMap(savedInstanceState);

    MultiSourceOverlayManager o = new MultiSourceOverlayManager(mapView);
    o.setMarkerOverlay(new MarkerOverlay());
    o.setMarkerVisible();
    mapView.setOverlayManger(o);

    if (getIntent() != null
        && getIntent().getExtras() != null
        && getIntent().getExtras().containsKey(MapsActivity.MSM_MAP)) {
      o.loadMap((MSMMap) getIntent().getExtras().getSerializable(MapsActivity.MSM_MAP));
    }

    mapView.setLayoutParams(
        new LayoutParams(
            RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT));

    mapView.setClickable(true);
    mapView.setBuiltInZoomControls(true);

    // add coordinates control
    mapView.addControl(new CoordinateControl(mapView, true));

    // add "location" control connected to the button
    LocationControl lc = new LocationControl(mapView);
    lc.setActivationButton(buttonLocation);
    mapView.addControl(lc);

    centerMapFileAndAddMarkers();
  }
Exemplo n.º 2
0
  /**
   * Add controls to the mapView and to the Buttons
   *
   * @param savedInstanceState
   */
  private void addControls(Bundle savedInstanceState) {
    String action = getIntent().getAction();
    Log.v("MapsActivity", "action: " + action);

    // Coordinate Control
    mapView.addControl(new CoordinateControl(mapView, true));
    List<MapControl> group = new ArrayList<MapControl>();

    // Info Control
    MapInfoControl ic;
    if (getIntent().hasExtra(PARAMETERS.CUSTOM_MAPINFO_CONTROL)) {
      ic = (MapInfoControl) getIntent().getParcelableExtra(PARAMETERS.CUSTOM_MAPINFO_CONTROL);
      ic.activity = this;
      ic.mapView = mapView;
      ic.instantiateListener();
    } else {
      ic = new MapInfoControl(mapView, this);
    }
    ic.setActivationButton((ImageButton) findViewById(R.id.ButtonInfo));

    mapView.addControl(ic);

    if (!Intent.ACTION_VIEW.equals(action)) {
      Log.v("MapsActivity", "Adding MarkerControl");

      // Marker Control
      MarkerControl mc = new MarkerControl(mapView);
      // activation button
      ImageButton mcbmb = (ImageButton) findViewById(R.id.ButtonMarker);
      mcbmb.setVisibility(View.VISIBLE);
      mc.setActivationButton(mcbmb);
      // info button  // TODO: do we need this button?
      ImageButton mcib = (ImageButton) findViewById(R.id.marker_info_button);
      mcib.setVisibility(View.VISIBLE);
      mc.setInfoButton(mcib);

      mapView.addControl(mc);
      group.add(mc);
      mc.setGroup(group);
      mc.setMode(MarkerControl.MODE_EDIT);
    }

    // My location Control
    LocationControl lc = new LocationControl(mapView);
    lc.setActivationButton((ImageButton) findViewById(R.id.ButtonLocation));
    mapView.addControl(lc);

    // create and add group
    group.add(ic);

    ic.setGroup(group);

    // TODO move this in a control

    // Set modes for controls
    if (Intent.ACTION_VIEW.equals(action)) {
      ic.setMode(MapInfoControl.MODE_VIEW);
    } else if (Intent.ACTION_EDIT.equals(action)) {
      ic.setMode(MapInfoControl.MODE_EDIT);
      // Default edit mode
    } else {
      ic.setMode(MapInfoControl.MODE_EDIT);
    }
    if (savedInstanceState != null) {
      for (MapControl c : mapView.getControls()) {
        c.restoreState(savedInstanceState);
      }
    }
  }