コード例 #1
0
  @Kroll.method
  public void deselectAnnotation(Object[] args) {
    String title = null;
    AnnotationProxy selectedAnnotation = null;
    if (args.length > 0) {
      if (args[0] instanceof AnnotationProxy) {
        selectedAnnotation = (AnnotationProxy) args[0];
        title = TiConvert.toString(selectedAnnotation.getProperty("title"));
      } else if (args[0] instanceof String) {
        title = TiConvert.toString(args[0]);
      }
    }
    if (title != null) {
      boolean animate = false;

      if (args.length > 1) {
        animate = TiConvert.toBoolean(args[1]);
      }

      if (mapView == null) {
        int numSelectedAnnotations = selectedAnnotations.size();
        for (int i = 0; i < numSelectedAnnotations; i++) {
          if ((selectedAnnotations.get(i)).title.equals(title)) {
            selectedAnnotations.remove(i);
          }
        }
      } else {
        mapView.selectAnnotation(false, title, selectedAnnotation, animate, false);
      }
    }
  }
コード例 #2
0
  @Kroll.method
  public void selectAnnotation(Object[] args) {
    AnnotationProxy selAnnotation = null;
    String title = null;
    boolean animate = false;
    boolean center = true; // keep existing default behavior

    if (args != null && args.length > 0) {
      if (args[0] instanceof HashMap) {
        HashMap<String, Object> params = (HashMap) args[0];

        Object selectedAnnotation = params.get(TiC.PROPERTY_ANNOTATION);
        if (selectedAnnotation instanceof AnnotationProxy) {
          selAnnotation = (AnnotationProxy) selectedAnnotation;
          title = TiConvert.toString(selAnnotation.getProperty(TiC.PROPERTY_TITLE));
        } else {
          title = TiConvert.toString(params, TiC.PROPERTY_TITLE);
        }

        Object animateProperty = params.containsKey(TiC.PROPERTY_ANIMATE);
        if (animateProperty != null) {
          animate = TiConvert.toBoolean(animateProperty);
        }

        Object centerProperty = params.containsKey(TiC.PROPERTY_CENTER);
        if (centerProperty != null) {
          center = TiConvert.toBoolean(centerProperty);
        }

      } else {
        if (args[0] instanceof AnnotationProxy) {
          selAnnotation = (AnnotationProxy) args[0];
          title = TiConvert.toString(selAnnotation.getProperty(TiC.PROPERTY_TITLE));

        } else if (args[0] instanceof String) {
          title = TiConvert.toString(args[0]);
        }

        if (args.length > 1) {
          animate = TiConvert.toBoolean(args[1]);
        }
      }
    }

    if (title != null) {
      if (mapView == null) {
        Log.i(TAG, "calling selectedAnnotations.add", Log.DEBUG_MODE);
        selectedAnnotations.add(
            new TiMapView.SelectedAnnotation(title, selAnnotation, animate, center));
      } else {
        Log.i(TAG, "calling selectedAnnotations.add2", Log.DEBUG_MODE);
        mapView.selectAnnotation(true, title, selAnnotation, animate, center);
      }
    }
  }