Search in sources :

Example 36 with LatLngBounds

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);
}
Also used : HashMap(java.util.HashMap) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds)

Example 37 with LatLngBounds

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());
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) LatLng(com.google.android.gms.maps.model.LatLng)

Example 38 with LatLngBounds

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);
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) LatLng(com.google.android.gms.maps.model.LatLng)

Example 39 with LatLngBounds

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));
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) LatLng(com.google.android.gms.maps.model.LatLng)

Example 40 with LatLngBounds

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();
        }
    });
}
Also used : Status(com.google.android.gms.common.api.Status) PlaceImpl(com.google.android.gms.location.places.internal.PlaceImpl) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) GmsMapsTypeHelper.fromLatLngBounds(org.microg.gms.maps.GmsMapsTypeHelper.fromLatLngBounds) Intent(android.content.Intent) TextView(android.widget.TextView) SearchView(android.support.v7.widget.SearchView) View(android.view.View) TextView(android.widget.TextView) BackendMapView(org.microg.gms.maps.BackendMapView) MapPosition(org.oscim.core.MapPosition) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)42 LatLng (com.google.android.gms.maps.model.LatLng)27 CameraUpdate (com.google.android.gms.maps.CameraUpdate)11 Marker (com.google.android.gms.maps.model.Marker)6 Intent (android.content.Intent)5 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)5 ArrayList (java.util.ArrayList)5 View (android.view.View)4 JSONException (org.json.JSONException)4 Handler (android.os.Handler)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 AutocompletePrediction (com.google.android.gms.location.places.AutocompletePrediction)3 AutocompletePredictionBuffer (com.google.android.gms.location.places.AutocompletePredictionBuffer)3 GoogleMap (com.google.android.gms.maps.GoogleMap)3 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)3 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 SuppressLint (android.annotation.SuppressLint)2 Cursor (android.database.Cursor)2