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);
}
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);
}
Aggregations