Search in sources :

Example 46 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.

the class MapboxUtil method convertToLatLng.

public static LatLng convertToLatLng(Feature feature) {
    Point symbolPoint = (Point) feature.getGeometry();
    Position position = symbolPoint.getCoordinates();
    return new LatLng(position.getLatitude(), position.getLongitude());
}
Also used : Position(com.mapbox.services.commons.models.Position) CameraPosition(com.mapbox.mapboxsdk.camera.CameraPosition) Point(com.mapbox.services.commons.geojson.Point) ILatLng(com.mapbox.mapboxsdk.geometry.ILatLng) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 47 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.

the class MapboxUtil method createLatLngAnimator.

private static Animator createLatLngAnimator(LatLng currentPosition, LatLng targetPosition, final MapboxMap mapboxMap) {
    ValueAnimator latLngAnimator = ValueAnimator.ofObject(new LatLngEvaluator(), currentPosition, targetPosition);
    latLngAnimator.setDuration(CAMERA_ANIMATION_TIME);
    latLngAnimator.setInterpolator(new FastOutSlowInInterpolator());
    latLngAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {

        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mapboxMap.setLatLng((LatLng) animation.getAnimatedValue());
        }
    });
    return latLngAnimator;
}
Also used : FastOutSlowInInterpolator(android.support.v4.view.animation.FastOutSlowInInterpolator) ILatLng(com.mapbox.mapboxsdk.geometry.ILatLng) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) ValueAnimator(android.animation.ValueAnimator)

Example 48 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.

the class VectorMapFragment method moveCenterInAndOpen.

public void moveCenterInAndOpen(String id, double latitude, double longitude) {
    if (busStopPlugin != null) {
        busStopPlugin.updateBusStops(new LatLng(latitude, longitude));
        busStopPlugin.moveCenterInAndOpen(id);
    }
}
Also used : LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Example 49 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.

the class VectorMapFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    Log.d("VectorMapFragment", "onViewCreated");
    super.onViewCreated(view, savedInstanceState);
    getMapAsync(new OnMapReadyCallback() {

        @Override
        public void onMapReady(MapboxMap resMapboxMap) {
            mapboxMap = resMapboxMap;
            clickListeners = new ArrayList<>();
            // mapboxMap.getUiSettings().setCompassImage(ContextCompat.getDrawable(getContext(), R.drawable.direction_arrow));
            mapboxMap.addOnMapClickListener(new MapboxMap.OnMapClickListener() {

                @Override
                public void onMapClick(@NonNull LatLng point) {
                    for (MultiLayerOnMapClickListener listener : clickListeners) {
                        if (listener.onMapClick(point)) {
                            return;
                        }
                    }
                }
            });
            locationEngine = new MultiLocationEngine();
            mapboxMap.getUiSettings().setCompassMargins(0, 27 * getResources().getDisplayMetrics().heightPixels / 100, 4 * getResources().getDisplayMetrics().widthPixels / 100, 0);
            onBusEngine = new OnBusEngine(mapboxMap);
            busStopPlugin = new BusStopPlugin(mapboxMap, getContext(), VectorMapFragment.this, onBusEngine);
            busUserPlugin = new BusUserPlugin(mapView, mapboxMap, locationEngine, VectorMapFragment.this, onBusEngine);
            clickListeners.add(busUserPlugin.getOnMapClickListener());
            clickListeners.add(busStopPlugin.getOnMapClickListener());
            outOfBusStopStackFrame = new MainActivity.OnBackButtonStack() {

                @Override
                public void onPressBackButton() {
                    busStopPlugin.clearSelectedFeature();
                }
            };
            mapboxMap.addOnScrollListener(new MapboxMap.OnScrollListener() {

                @Override
                public void onScroll() {
                    centerButton.deselectButton();
                    busUserPlugin.setTrackingEnabled(false);
                }
            });
            centerButton = new LocationToggleButton((ImageButton) getActivity().findViewById(R.id.floating_button_center), new LocationToggleButton.OnToggleButtonCheck() {

                @Override
                public void onButtonSelected() {
                    Log.d("VectorMapFragment", "onButtonSelected");
                    if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
                        return;
                    }
                    mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(locationEngine.getLastLocation().getLatitude(), locationEngine.getLastLocation().getLongitude()), 16));
                    busUserPlugin.setTrackingEnabled(true);
                }

                @Override
                public void onButtonUnselected() {
                    busUserPlugin.setTrackingEnabled(false);
                }
            }, true);
            enableLocationPlugin();
            if (savedBus != null) {
                changeToOnBus(savedBus);
                savedBus = null;
            }
        }
    });
}
Also used : BusUserPlugin(cl.smartcities.isci.transportinspector.map.plugin.userPlugin.BusUserPlugin) MultiLocationEngine(cl.smartcities.isci.transportinspector.map.engine.MultiLocationEngine) ArrayList(java.util.ArrayList) OnMapReadyCallback(com.mapbox.mapboxsdk.maps.OnMapReadyCallback) MultiLayerOnMapClickListener(cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener) MultiLayerOnMapClickListener(cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener) NonNull(android.support.annotation.NonNull) OnBusEngine(cl.smartcities.isci.transportinspector.map.engine.OnBusEngine) BusStopPlugin(cl.smartcities.isci.transportinspector.map.plugin.busStopPlugin.BusStopPlugin) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) MapboxMap(com.mapbox.mapboxsdk.maps.MapboxMap)

Example 50 with LatLng

use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.

the class OnBusEngine method setOnBus.

public void setOnBus(ServerSentBus bus) {
    this.bus = bus;
    RouteHelper helper = new RouteHelper(TranSappApplication.getAppContext());
    ArrayList<LatLng> points = helper.getRoute(bus.getService(), bus.getDirection());
    busPolyline = addBusRoutePolyline(points, Constants.BUS_COLOR.get(bus.getColorArrayIndex()));
    setBusStopDrawable();
    getRouteBusStop();
}
Also used : RouteHelper(cl.smartcities.isci.transportinspector.database.RouteHelper) LatLng(com.mapbox.mapboxsdk.geometry.LatLng)

Aggregations

LatLng (com.mapbox.mapboxsdk.geometry.LatLng)57 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)12 ArrayList (java.util.ArrayList)10 Point (com.mapbox.geojson.Point)7 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)7 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