Package de.fhpotsdam.unfolding.examples

Source Code of de.fhpotsdam.unfolding.examples.SimplePositionConversionMapApp

package de.fhpotsdam.unfolding.examples;

import processing.core.PApplet;

import de.fhpotsdam.unfolding.UnfoldingMap;
import de.fhpotsdam.unfolding.examples.marker.SimpleMarkerManagerApp;
import de.fhpotsdam.unfolding.geo.Location;
import de.fhpotsdam.unfolding.utils.MapUtils;
import de.fhpotsdam.unfolding.utils.ScreenPosition;

/**
* Simple map app showing how to convert screen position to geo-location, and vice versa.
*
* For automatic conversion from geo-location to screen, take a look at Unfolding's marker mechanism.
* Start at {@link SimpleMarkeApp} and {@link SimpleMarkerManagerApp}.
*/
public class SimplePositionConversionMapApp extends PApplet {

  UnfoldingMap map;

  public void setup() {
    size(800, 600, OPENGL);

    map = new UnfoldingMap(this);
    MapUtils.createDefaultEventDispatcher(this, map);
  }

  public void draw() {
    map.draw();

    fill(215, 0, 0, 100);
    // Shows latitude,longitude at mouse position
    Location location = map.getLocation(mouseX, mouseY);
    text("geo:" + location.toString(), mouseX, mouseY);

    // Shows marker at Berlin location
    Location loc = new Location(52.5f, 13.4f);
    ScreenPosition pos = map.getScreenPosition(loc);
    ellipse(pos.x, pos.y, 20, 20);

    String berlinDescription = "Berlin at pixel (" + (int) pos.x + "," + (int) pos.y + ")";
    text(berlinDescription, pos.x, pos.y);
  }

  public static void main(String[] args) {
    PApplet.main(new String[] { "de.fhpotsdam.unfolding.examples.SimplePositionConversionMapApp" });
  }
}
TOP

Related Classes of de.fhpotsdam.unfolding.examples.SimplePositionConversionMapApp

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.