Search in sources :

Example 1 with GeoJsonSource

use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.

the class PolylineEngine method setupBusRouteSource.

private void setupBusRouteSource(MapboxMap mapboxMap) {
    busRouteStartSource = new GeoJsonSource(LocationLayerConstants.SOURCE_USER_BUS_ROUTE_START, busRouteStartFeature);
    mapboxMap.addSource(busRouteStartSource);
    busRouteEndSource = new GeoJsonSource(LocationLayerConstants.SOURCE_USER_BUS_ROUTE_END, busRouteEndFeature);
    mapboxMap.addSource(busRouteEndSource);
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource)

Example 2 with GeoJsonSource

use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.

the class BusStopPlugin method setupBusStopSource.

private void setupBusStopSource() {
    busStopSource = new GeoJsonSource(SOURCE_BUS_STOPS, busStopFeatures);
    mapboxMap.addSource(busStopSource);
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource)

Example 3 with GeoJsonSource

use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.

the class BusUserPlugin method getOnMapClickListener.

public MultiLayerOnMapClickListener getOnMapClickListener() {
    return new MultiLayerOnMapClickListener() {

        @Override
        public boolean onMapClick(@NonNull LatLng point) {
            PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
            final List<Feature> allFeatures = mapboxMap.queryRenderedFeatures(screenPoint);
            Collections.reverse(allFeatures);
            for (Feature feature : allFeatures) {
                if (feature.hasProperty(LocationLayerConstants.PROPERTY_ON_BUS) && feature.getBooleanProperty(LocationLayerConstants.PROPERTY_ON_BUS).equals(true)) {
                    // BUS FEATURE CLICK
                    final List<Feature> infoWindowFeature = mapboxMap.queryRenderedFeatures(screenPoint, LocationLayerConstants.LOCATION_LAYER_INFO_WINDOW);
                    if (!infoWindowFeature.isEmpty()) {
                        PeriodicRequestHandler periodicRequestHandler = new PeriodicRequestHandler(TranSappApplication.getAppContext(), null, null);
                        BusClickHandler handler = new BusClickHandler(TranSappApplication.getAppContext().getResources(), periodicRequestHandler, listener);
                        PointF symbolScreenPoint = mapboxMap.getProjection().toScreenLocation(MapboxUtil.convertToLatLng(feature));
                        if (handler.handleInfoWindowClick(currentUserBus, screenPoint, symbolScreenPoint, viewMap, true)) {
                            return true;
                        }
                        minimizeFeature();
                        return true;
                    }
                    userLocationFeature.addBooleanProperty(LocationLayerConstants.PROPERTY_MAXIMIZED, true);
                    GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
                    if (locationGeoJsonSource == null) {
                        return true;
                    }
                    locationGeoJsonSource.setGeoJson(userLocationFeature);
                    return true;
                }
            }
            // we didn't find a click event on any layer
            minimizeFeature();
            return false;
        }
    };
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) PeriodicRequestHandler(cl.smartcities.isci.transportinspector.periodicRequest.PeriodicRequestHandler) NonNull(android.support.annotation.NonNull) PointF(android.graphics.PointF) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) MultiLayerOnMapClickListener(cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener) Feature(com.mapbox.services.commons.geojson.Feature) BusClickHandler(cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler)

Example 4 with GeoJsonSource

use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.

the class BusUserPlugin method setOnBus.

private void setOnBus() {
    final GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
    if (locationGeoJsonSource == null) {
        return;
    }
    this.directionDetectionEngine = new DirectionEngine(10, currentUserBus.getService());
    ArrayList<IconBuilder> buildingList = new ArrayList<>();
    buildingList.add(new UserBusIconsBuilder(currentUserBus).toBuilder());
    GenerateViewIconTask task = new GenerateViewIconTask(new GenerateViewIconTask.ImageLoaderListener() {

        @Override
        public void onImageGenResult(HashMap<String, View> viewMap, HashMap<String, Bitmap> bitmapHashMap) {
            if (mapboxMap != null) {
                mapboxMap.addImages(bitmapHashMap);
            } else {
                return;
            }
            BearingEngine.Orientation orientation;
            if (currentUserBus.isFlipped()) {
                userLocationFeature.addStringProperty(LocationLayerConstants.PROPERTY_ORIENTATION, "LEFT");
                orientation = BearingEngine.Orientation.Left;
            } else {
                userLocationFeature.addStringProperty(LocationLayerConstants.PROPERTY_ORIENTATION, "RIGHT");
                orientation = BearingEngine.Orientation.Right;
            }
            userLocationFeature.addBooleanProperty(LocationLayerConstants.PROPERTY_ON_BUS, true);
            bearingEngine = new BearingEngine(mapboxMap, previousPoint, orientation);
            if (currentUserBus.getDirection() != null && !currentUserBus.getDirection().isEmpty()) {
                onBusEngine.setOnBus(currentUserBus);
            }
            locationGeoJsonSource.setGeoJson(userLocationFeature);
            mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(MapboxUtil.convertToLatLng(userLocationFeature)));
        }
    }, viewMap, buildingList);
    task.execute();
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) GenerateViewIconTask(cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask) DirectionEngine(cl.smartcities.isci.transportinspector.map.engine.DirectionEngine) IconBuilder(cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder) ArrayList(java.util.ArrayList) UserBusIconsBuilder(cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder) MapView(com.mapbox.mapboxsdk.maps.MapView) View(android.view.View) Bitmap(android.graphics.Bitmap) BearingEngine(cl.smartcities.isci.transportinspector.map.engine.BearingEngine)

Example 5 with GeoJsonSource

use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.

the class BusUserPlugin method setBusAvatarId.

public void setBusAvatarId(int busAvatarId) {
    if (currentUserBus == null) {
        return;
    }
    currentUserBus.setAvatarId(busAvatarId);
    ArrayList<IconBuilder> buildingList = new ArrayList<>();
    buildingList.add(new UserBusIconsBuilder(currentUserBus).toBuilder());
    GenerateViewIconTask task = new GenerateViewIconTask(new GenerateViewIconTask.ImageLoaderListener() {

        @Override
        public void onImageGenResult(HashMap<String, View> viewMap, HashMap<String, Bitmap> bitmapHashMap) {
            if (mapboxMap != null) {
                mapboxMap.addImages(bitmapHashMap);
            } else {
                return;
            }
            GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
            if (locationGeoJsonSource != null) {
                locationGeoJsonSource.setGeoJson(userLocationFeature);
            }
        }
    }, viewMap, buildingList);
    task.execute();
}
Also used : GeoJsonSource(com.mapbox.mapboxsdk.style.sources.GeoJsonSource) GenerateViewIconTask(cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask) IconBuilder(cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder) ArrayList(java.util.ArrayList) UserBusIconsBuilder(cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder) MapView(com.mapbox.mapboxsdk.maps.MapView) View(android.view.View) Bitmap(android.graphics.Bitmap)

Aggregations

GeoJsonSource (com.mapbox.mapboxsdk.style.sources.GeoJsonSource)15 Bitmap (android.graphics.Bitmap)3 View (android.view.View)3 UserBusIconsBuilder (cl.smartcities.isci.transportinspector.map.model.bus.UserBusIconsBuilder)3 IconBuilder (cl.smartcities.isci.transportinspector.map.model.busStop.IconBuilder)3 GenerateViewIconTask (cl.smartcities.isci.transportinspector.map.tasks.GenerateViewIconTask)3 MapView (com.mapbox.mapboxsdk.maps.MapView)3 ArrayList (java.util.ArrayList)3 GeoJsonOptions (com.mapbox.mapboxsdk.style.sources.GeoJsonOptions)2 Feature (com.mapbox.services.commons.geojson.Feature)2 PointF (android.graphics.PointF)1 NonNull (android.support.annotation.NonNull)1 BearingEngine (cl.smartcities.isci.transportinspector.map.engine.BearingEngine)1 DirectionEngine (cl.smartcities.isci.transportinspector.map.engine.DirectionEngine)1 BusClickHandler (cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler)1 MultiLayerOnMapClickListener (cl.smartcities.isci.transportinspector.map.utils.MultiLayerOnMapClickListener)1 PeriodicRequestHandler (cl.smartcities.isci.transportinspector.periodicRequest.PeriodicRequestHandler)1 JsonObject (com.google.gson.JsonObject)1 FeatureCollection (com.mapbox.geojson.FeatureCollection)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1