use of com.google.android.gms.maps.model.LatLngBounds in project wigle-wifi-wardriving by wiglenet.
the class KmlFeatureParser method createGroundOverlay.
/**
* Creates a new GroundOverlay object (created if a GroundOverlay tag is read by the
* XmlPullParser) and assigns specific elements read from the parser to the GroundOverlay
*/
/* package */
static KmlGroundOverlay createGroundOverlay(XmlPullParser parser) throws IOException, XmlPullParserException {
float drawOrder = 0.0f;
float rotation = 0.0f;
int visibility = 1;
String imageUrl = null;
LatLngBounds latLonBox;
HashMap<String, String> properties = new HashMap<String, String>();
HashMap<String, Double> compassPoints = new HashMap<String, Double>();
int eventType = parser.getEventType();
while (!(eventType == END_TAG && parser.getName().equals("GroundOverlay"))) {
if (eventType == START_TAG) {
if (parser.getName().equals("Icon")) {
imageUrl = getImageUrl(parser);
} else if (parser.getName().equals("drawOrder")) {
drawOrder = Float.parseFloat(parser.nextText());
} else if (parser.getName().equals("visibility")) {
visibility = Integer.parseInt(parser.nextText());
} else if (parser.getName().equals("ExtendedData")) {
properties.putAll(setExtendedDataProperties(parser));
} else if (parser.getName().equals("rotation")) {
rotation = getRotation(parser);
} else if (parser.getName().matches(PROPERTY_REGEX) || parser.getName().equals("color")) {
properties.put(parser.getName(), parser.nextText());
} else if (parser.getName().matches(COMPASS_REGEX)) {
compassPoints.put(parser.getName(), Double.parseDouble(parser.nextText()));
}
}
eventType = parser.next();
}
latLonBox = createLatLngBounds(compassPoints.get("north"), compassPoints.get("south"), compassPoints.get("east"), compassPoints.get("west"));
return new KmlGroundOverlay(imageUrl, latLonBox, drawOrder, visibility, properties, rotation);
}
use of com.google.android.gms.maps.model.LatLngBounds in project wigle-wifi-wardriving by wiglenet.
the class GeoJsonFeatureTest method testGetBoundingBox.
public void testGetBoundingBox() {
feature = new GeoJsonFeature(null, null, null, null);
assertNull(feature.getBoundingBox());
LatLngBounds boundingBox = new LatLngBounds(new LatLng(-20, -20), new LatLng(50, 50));
feature = new GeoJsonFeature(null, null, null, boundingBox);
assertEquals(boundingBox, feature.getBoundingBox());
}
use of com.google.android.gms.maps.model.LatLngBounds in project wigle-wifi-wardriving by wiglenet.
the class GeoJsonParser method parseBoundingBox.
/**
* Parses a bounding box given as a JSONArray of 4 elements in the order of lowest values for
* all axes followed by highest values. Axes order of a bounding box follows the axes order of
* geometries.
*
* @param coordinates array of 4 coordinates
* @return LatLngBounds containing the coordinates of the bounding box
* @throws JSONException if the bounding box could not be parsed
*/
private static LatLngBounds parseBoundingBox(JSONArray coordinates) throws JSONException {
// Lowest values for all axes
LatLng southWestCorner = new LatLng(coordinates.getDouble(1), coordinates.getDouble(0));
// Highest value for all axes
LatLng northEastCorner = new LatLng(coordinates.getDouble(3), coordinates.getDouble(2));
return new LatLngBounds(southWestCorner, northEastCorner);
}
use of com.google.android.gms.maps.model.LatLngBounds in project android_packages_apps_GmsCore by microg.
the class GmsMapsTypeHelper method toLatLngBounds.
public static LatLngBounds toLatLngBounds(Box box) {
double minLon = MercatorProjection.toLongitude(box.xmin);
double maxLon = MercatorProjection.toLongitude(box.xmax);
double minLat = MercatorProjection.toLatitude(box.ymax);
double maxLat = MercatorProjection.toLatitude(box.ymin);
if (Double.isNaN(minLon) || Double.isNaN(maxLon) || Double.isNaN(minLat) || Double.isNaN(maxLat))
minLon = maxLon = minLat = maxLat = 0;
return new LatLngBounds(new LatLng(minLat, minLon), new LatLng(maxLat, maxLon));
}
use of com.google.android.gms.maps.model.LatLngBounds in project android_packages_apps_GmsCore by microg.
the class PlacePickerActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
resultIntent = new Intent();
place = new PlaceImpl();
setContentView(R.layout.pick_place);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
if (getIntent().hasExtra(EXTRA_PRIMARY_COLOR)) {
toolbar.setBackgroundColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR, 0));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0));
((TextView) findViewById(R.id.place_picker_title)).setTextColor(getIntent().getIntExtra(EXTRA_PRIMARY_COLOR_DARK, 0));
}
mapView = (BackendMapView) findViewById(R.id.map);
mapView.map().getEventLayer().enableRotation(false);
mapView.map().getEventLayer().enableTilt(false);
mapView.map().events.bind(this);
LatLngBounds latLngBounds = getIntent().getParcelableExtra(LocationConstants.EXTRA_BOUNDS);
if (latLngBounds != null) {
place.viewport = latLngBounds;
MapPosition mp = new MapPosition();
mp.setByBoundingBox(fromLatLngBounds(latLngBounds), mapView.map().getWidth(), mapView.map().getHeight());
mapView.map().getMapPosition(mp);
} else {
if (ActivityCompat.checkSelfPermission(PlacePickerActivity.this, ACCESS_FINE_LOCATION) != PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(PlacePickerActivity.this, new String[] { ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION }, 0);
} else {
updateMapFromLocationManager();
}
}
findViewById(R.id.place_picker_select).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resultIntent.putExtra(LocationConstants.EXTRA_STATUS, SafeParcelUtil.asByteArray(new Status(CommonStatusCodes.SUCCESS)));
resultIntent.putExtra(LocationConstants.EXTRA_PLACE, SafeParcelUtil.asByteArray(place));
resultIntent.putExtra(LocationConstants.EXTRA_FINAL_BOUNDS, SafeParcelUtil.asByteArray(place.viewport));
setResult(RESULT_OK, resultIntent);
finish();
}
});
}
Aggregations