Code example for Matrix

Methods: mapVectors, postTranslate

0
   */ 
  public float getZoomLevel() { 
    return imageToScreen.getZoomLevel();
  } 
 
  /** 
   * set the zoom factor being used currently when displaying the map 
   */ 
  public void setZoomLevel(float zoom) {
    imageToScreen.setZoomLevel(zoom);
  } 
 
  /** 
   * Zooms the map image on screen by the given factor. 
   * 
   * @param factor to zoom the map. 0-1 zooms out, 1- zooms in 
   */ 
  public void zoom(float factor) {
    imageToScreen.zoom(factor);
  } 
 
  /** 
   * Returns float[] containing longitude and latitude of the screen center 
   * point. If the system fails to convert screen to image coordinates or image 
   * to geo coordinates, returns 'null' (that should never happen). 
   * 
   * @return geo coordinates (longitude and latitude, in that order) of the 
   *         screen center point 
   */ 
  public float[] getScreenCenterGeoLocation() { 
    float[] location = imageToScreen.getScreenCenterCoordinates(null);
    if (location == null) {
      return null; 
    } 
    // Convert screen center into image coordinates 
    imageToScreen.convertScreenToImageCoordinates(location);
    return geoToImage.convertImageToGeoCoordinates(location);
  } 
 
  public float[] getMapCenterGeoLocation(float[] result) {
    return geoToImage.getMapCenterGeoLocation(result);
  } 
 
  public boolean centerOnGeoLocation(float longitude, float latitude) {
    // Check that the location is within the map boundaries 
    float[] location = new float[] { longitude, latitude };
    geoToImage.convertGeoToImageCoordinates(location);
    if (location[0] < 0 || geoToImage.getImageWidth() < location[0] ||
        location[1] < 0 || geoToImage.getImageHeight() < location[1]) {
      return false; 
    } 
 
    imageToScreen.convertImageToScreenCoordinates(location);
    View screenView = imageToScreen.getScreenView();
    float dx = screenView.getWidth() / 2 - location[0];
    float dy = screenView.getHeight() / 2 - location[1];
    imageToScreen.translate(dx, dy);
    return true; 
  } 
 
  public float[] convertGeoToScreenCoordinates(float[] location) {
    geoToImage.convertGeoToImageCoordinates(location);
    return imageToScreen.convertImageToScreenCoordinates(location);
  } 
}