コード例 #1
0
 @Override
 public void onBackPressed() {
   // 重写onBackPressed,将字段markerConfigDialog必须置为null,以保证消除之前的引用
   markerConfigDialog.dismiss();
   markerConfigDialog = null;
   super.onBackPressed();
 }
コード例 #2
0
 @Override
 protected void onPrepareDialog(int id, Dialog dialog) {
   switch (id) {
     case MARKERCONFIG_DIALOG:
       if (markerConfigDialog != null && longTouchGeoPoint != null) {
         Window window = markerConfigDialog.getWindow();
         WindowManager.LayoutParams lp = window.getAttributes();
         // 设置对话框初始位置为左上角
         lp.gravity = Gravity.LEFT | Gravity.TOP;
         // lp.x与lp.y表示相对于原始位置的偏移
         // (touchX, touchY)为触屏位置坐标,坐标系以屏幕左上角为(0, 0)
         lp.x = touchX;
         lp.y = touchY;
         // 重新设置对话框位置
         window.setAttributes(lp);
         markerConfigDialog.setLongTouchGeoPoint(longTouchGeoPoint);
       }
       break;
     case README_DIALOG:
       ReadmeDialog readmeDialog = (ReadmeDialog) dialog;
       readmeDialog.setReadmeText(getResources().getString(R.string.overlayeventdemo_readme));
       break;
     default:
       break;
   }
   super.onPrepareDialog(id, dialog);
 }
コード例 #3
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   // group, item id, order, title
   menu.add(0, 1, 0, R.string.clearall);
   return true;
 }
コード例 #4
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Drawable drawableBlue = getResources().getDrawable(R.drawable.blue_pin);
    blueMarkerOverlay = new DefaultItemizedOverlay(drawableBlue);

    Drawable drawableGreen = getResources().getDrawable(R.drawable.green_pin);
    greenMarkerOverlay = new DefaultItemizedOverlay(drawableGreen);

    Drawable drawableRed = getResources().getDrawable(R.drawable.red_pin);
    redMarkerOverlay = new DefaultItemizedOverlay(drawableRed);

    Drawable drawableYellow = getResources().getDrawable(R.drawable.yellow_pin);
    yellowMarkerOverlay = new DefaultItemizedOverlay(drawableYellow);

    // 动态投影为4326的地图,防止投影坐标系设置中心点无效,图层叠加等设置经纬度坐标无效。
    //        CoordinateReferenceSystem crs = new CoordinateReferenceSystem();
    //        crs.wkid = 4326;
    //        baseLayerView.setCRS(crs);

    mapView.getController().setZoom(6);
    //        mapView.getController().setCenter(new Point2D(116.391468, 39.904491));
    mapView.setBuiltInZoomControls(false);
    mapView.addMapViewEventListener(new MapViewEventAdapter());

    TouchOverlay touchOverlay = new TouchOverlay();
    mapView.getOverlays().add(touchOverlay);

    mapView.getOverlays().add(blueMarkerOverlay);
    mapView.getOverlays().add(greenMarkerOverlay);
    mapView.getOverlays().add(redMarkerOverlay);
    mapView.getOverlays().add(yellowMarkerOverlay);

    // 构造一个markerConfigDialog,showDialog时即可直接返回
    markerConfigDialog = new MarkerConfigDialog(this, R.style.dialogTheme);

    service = new PreferencesService(this);
    Map<String, Boolean> params = service.getReadmeEnable("OverlayEventDemo");
    boolean isReadmeEnable = params.get("readme");
    if (isReadmeEnable) {
      showDialog(README_DIALOG);
    }
    helpBtn.setVisibility(View.VISIBLE);
    helpBtn.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            showDialog(README_DIALOG);
          }
        });
  }
コード例 #5
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   super.onConfigurationChanged(newConfig);
 }