Search in sources :

Example 16 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class OsmAnimatorUpdateListener method onAnimationUpdate.

@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
    float animatedValue = (Float) valueAnimator.getAnimatedValue();
    Double lat = originPos.getLatitude() + latStep * animatedValue;
    Double lng = originPos.getLongitude() + lngStep * animatedValue;
    LatLng newPosition = new LatLng(lat, lng);
    mapboxMap.setCameraPosition(new CameraPosition.Builder().target(newPosition).build());
}
Also used : CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 17 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class LatLngBoundsUtils method enlarge.

public static LatLngBounds enlarge(LatLngBounds viewLatLngBounds, double factor) {
    double n = viewLatLngBounds.getLatNorth();
    double e = viewLatLngBounds.getLonEast();
    double s = viewLatLngBounds.getLatSouth();
    double w = viewLatLngBounds.getLonWest();
    double f = (factor - 1) / 2;
    return new LatLngBounds.Builder().include(new LatLng(n + f * (n - s), e + f * (e - w))).include(new LatLng(s - f * (n - s), w - f * (e - w))).build();
}
Also used : LatLngBounds(com.mapbox.mapboxsdk.geometry.LatLngBounds) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 18 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class Box method enlarge.

/**
 * Enlarge the Box.
 *
 * @param viewLatLngBounds The box to enlarge.
 * @param factor The factor to enlarge the box.
 * @return Box the Box enlarged.
 */
public static LatLngBounds enlarge(LatLngBounds viewLatLngBounds, double factor) {
    double n = viewLatLngBounds.getLatNorth();
    double e = viewLatLngBounds.getLonEast();
    double s = viewLatLngBounds.getLatSouth();
    double w = viewLatLngBounds.getLonWest();
    double f = (factor - 1) / 2;
    return new LatLngBounds.Builder().include(new LatLng(n + f * (n - s), e + f * (e - w))).include(new LatLng(s - f * (n - s), w - f * (e - w))).build();
}
Also used : LatLngBounds(com.mapbox.mapboxsdk.geometry.LatLngBounds) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 19 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class EditPoiManager method onPleaseCreateNoTagPoiEvent.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseCreateNoTagPoiEvent(PleaseCreateNoTagPoiEvent event) {
    Poi poi = new Poi();
    LatLng latLng = event.getLatLng();
    poi.setLatitude(latLng.getLatitude());
    poi.setLongitude(latLng.getLongitude());
    poi.setType(event.getPoiType());
    List<PoiTag> defaultTags = new ArrayList<>();
    for (PoiTypeTag poiTypeTag : poi.getType().getTags()) {
        if (poiTypeTag.getValue() != null) {
            // default tags should be set in the corresponding POI
            PoiTag poiTag = new PoiTag();
            poiTag.setKey(poiTypeTag.getKey());
            poiTag.setValue(poiTypeTag.getValue());
            defaultTags.add(poiTag);
        }
    }
    poi.setTags(defaultTags);
    poi.setUpdated(true);
    poiManager.savePoi(poi);
    poiManager.updatePoiTypeLastUse(event.getPoiType().getId());
    eventBus.post(new PoiNoTypeCreated());
}
Also used : PoiTag(io.jawg.osmcontributor.model.entities.PoiTag) PoiNoTypeCreated(io.jawg.osmcontributor.ui.events.map.PoiNoTypeCreated) ArrayList(java.util.ArrayList) Poi(io.jawg.osmcontributor.model.entities.Poi) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) PoiTypeTag(io.jawg.osmcontributor.model.entities.PoiTypeTag) Subscribe(org.greenrobot.eventbus.Subscribe)

Example 20 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project osm-contributor by jawg.

the class EditPoiManager method onPleaseApplyNodeRefPositionChange.

@Subscribe(threadMode = ThreadMode.ASYNC)
public void onPleaseApplyNodeRefPositionChange(PleaseApplyNodeRefPositionChange event) {
    Timber.d("Please apply noderef position change");
    LatLng newLatLng = event.getPoiPosition();
    // apply changes on the noderef
    PoiNodeRef poiNodeRef = poiNodeRefDao.queryForId(event.getPoiId());
    poiNodeRef.setOldPoiId(saveOldVersionOfPoiNodeRef(poiNodeRef));
    poiNodeRef.setLongitude(newLatLng.getLongitude());
    poiNodeRef.setLatitude(newLatLng.getLatitude());
    poiNodeRef.setUpdated(true);
    poiNodeRefDao.createOrUpdate(poiNodeRef);
}
Also used : LatLng(com.mapbox.mapboxsdk.geometry.LatLng) PoiNodeRef(io.jawg.osmcontributor.model.entities.PoiNodeRef) Subscribe(org.greenrobot.eventbus.Subscribe)

Aggregations

LatLng (com.mapbox.mapboxsdk.geometry.LatLng)56 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)12 ArrayList (java.util.ArrayList)10 Point (com.mapbox.geojson.Point)7 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)6 MapboxMap (com.mapbox.mapboxsdk.maps.MapboxMap)6 NonNull (android.support.annotation.NonNull)5 PointF (android.graphics.PointF)4 OnMapReadyCallback (com.mapbox.mapboxsdk.maps.OnMapReadyCallback)4 ValueAnimator (android.animation.ValueAnimator)3 MultiLocationEngine (cl.smartcities.isci.transportinspector.map.engine.MultiLocationEngine)3 MultiLayerOnMapClickListener (cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener)3 MarkerOptions (com.mapbox.mapboxsdk.annotations.MarkerOptions)3 Poi (io.jawg.osmcontributor.model.entities.Poi)3 Subscribe (org.greenrobot.eventbus.Subscribe)3 Intent (android.content.Intent)2 Location (android.location.Location)2 View (android.view.View)2 RouteHelper (cl.smartcities.isci.transportinspector.database.RouteHelper)2 BusClickHandler (cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler)2