Search in sources :

Example 1 with MapPolygon

use of com.here.android.mpa.mapping.MapPolygon in project here-android-sdk-examples by heremaps.

the class MapFragmentView method createPolygon.

/**
 * Create a MapPolygon and add the MapPolygon to active map view.
 */
private void createPolygon() {
    // create an bounding box centered at current cent
    GeoBoundingBox boundingBox = new GeoBoundingBox(m_map.getCenter(), 1000, 1000);
    // add boundingbox's four vertices to list of Geocoordinates.
    List<GeoCoordinate> coordinates = new ArrayList<GeoCoordinate>();
    coordinates.add(boundingBox.getTopLeft());
    coordinates.add(new GeoCoordinate(boundingBox.getTopLeft().getLatitude(), boundingBox.getBottomRight().getLongitude(), boundingBox.getTopLeft().getAltitude()));
    coordinates.add(boundingBox.getBottomRight());
    coordinates.add(new GeoCoordinate(boundingBox.getBottomRight().getLatitude(), boundingBox.getTopLeft().getLongitude(), boundingBox.getTopLeft().getAltitude()));
    // create GeoPolygon with list of GeoCoordinates.
    GeoPolygon geoPolygon = new GeoPolygon(coordinates);
    // create MapPolygon with GeoPolygon.
    m_polygon = new MapPolygon(geoPolygon);
    // set line color, fill color and line width
    m_polygon.setLineColor(Color.RED);
    m_polygon.setFillColor(Color.GRAY);
    m_polygon.setLineWidth(12);
    // add MapPolygon to map.
    m_map.addMapObject(m_polygon);
}
Also used : MapPolygon(com.here.android.mpa.mapping.MapPolygon) ArrayList(java.util.ArrayList) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) GeoBoundingBox(com.here.android.mpa.common.GeoBoundingBox) GeoPolygon(com.here.android.mpa.common.GeoPolygon)

Example 2 with MapPolygon

use of com.here.android.mpa.mapping.MapPolygon in project here-android-sdk-examples by heremaps.

the class MapFragmentView method addPolygonObject.

/**
 * Create a MapPolygon and add the MapPolygon to active map view.
 */
private void addPolygonObject() {
    // create an bounding box centered at current cent
    GeoBoundingBox boundingBox = new GeoBoundingBox(m_map.getCenter(), 1000, 1000);
    // add boundingbox's four vertices to list of Geocoordinates.
    List<GeoCoordinate> coordinates = new ArrayList<GeoCoordinate>();
    coordinates.add(boundingBox.getTopLeft());
    coordinates.add(new GeoCoordinate(boundingBox.getTopLeft().getLatitude(), boundingBox.getBottomRight().getLongitude(), boundingBox.getTopLeft().getAltitude()));
    coordinates.add(boundingBox.getBottomRight());
    coordinates.add(new GeoCoordinate(boundingBox.getBottomRight().getLatitude(), boundingBox.getTopLeft().getLongitude(), boundingBox.getTopLeft().getAltitude()));
    // create GeoPolygon with list of GeoCoordinates.
    GeoPolygon geoPolygon = new GeoPolygon(coordinates);
    // create MapPolygon with GeoPolygon.
    MapPolygon polygon = new MapPolygon(geoPolygon);
    // set line color, fill color and line width
    polygon.setLineColor(Color.RED);
    polygon.setFillColor(Color.GRAY);
    polygon.setLineWidth(12);
    // add MapPolygon to map.
    m_map.addMapObject(polygon);
    m_polygons.add(polygon);
}
Also used : MapPolygon(com.here.android.mpa.mapping.MapPolygon) ArrayList(java.util.ArrayList) GeoCoordinate(com.here.android.mpa.common.GeoCoordinate) GeoBoundingBox(com.here.android.mpa.common.GeoBoundingBox) GeoPolygon(com.here.android.mpa.common.GeoPolygon)

Aggregations

GeoBoundingBox (com.here.android.mpa.common.GeoBoundingBox)2 GeoCoordinate (com.here.android.mpa.common.GeoCoordinate)2 GeoPolygon (com.here.android.mpa.common.GeoPolygon)2 MapPolygon (com.here.android.mpa.mapping.MapPolygon)2 ArrayList (java.util.ArrayList)2