I'm developing an app that uses offline maps.
Now I need to implement offline navigation in the app.
Can I implement offline navigation?
UPD:
I tried grapphopper, but it doesn't work offline.
GeoPoint startPoint = new GeoPoint(41.4670689,69.5824818);
RoadManager roadManager = new GraphHopperRoadManager("API KEY", true);
ArrayList<GeoPoint> waypoints = new ArrayList<>();
waypoints.add(startPoint);
waypoints.add(new GeoPoint(41.3868364,69.4419728));
Road road = roadManager.getRoad(waypoints);
Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
map.getOverlays().add(roadOverlay);
map.getController().setCenter(startPoint);
You are using support for graphopper from osmbonuspack (GraphHopperRoadManager) which apparently does support only online functionality (it just calls the official Graphopper api).
You'll need to integrate the Graphopper library directly into you android project. And that's not as simple as you may think.
You'll need to:
1) Obtain openstreetmap data for your locality (in pbf format).
You can find sliced parts of the globe on internet. There are tools that will help you to cut out a region you need, if you want to work with some specific area.
2) Prepare data for graphopper
Clone the Graphopper project and import your OSM data
git clone git://github.com/graphhopper/graphhopper.git graphhopper
cd graphhopper
git checkout 0.10.0
./graphhopper.sh import your-area.pbf
This will creat a directory (probably next to your pbf named as {your-area}-gh) with preprocessed graphopper data. You have to include this directory in your app. You can add it to the assets directory or download it at runtime.
Note: There may be additional setup steps for the graphopper project, unfortunatelly I don't remember them (I did this integration 2 years ago). Navigating graphopper documentation can be a bit challenging but they have some community support and there are resources online. It can be done.
3) Include graphopper library into your project
They have an android demo app. So check how the library is integrated and used.
At the time of writing, the dependencies are specified in this way:
implementation(group: 'com.graphhopper', name: 'graphhopper-core', version: '0.10-SNAPSHOT') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
}
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'org.slf4j:slf4j-android:1.7.25'
But change '0.10.0-SHAPSHOT' to '0.10'. Also, you should have `jcenter()`` repository added in your project's root gradle file.
Note: versions do matter. Your library in app should have exactly the same version as core project you cloned to generate data. There may be incompatibilities in data format between versions. That's why I included git checkout 0.10.0 in the second step.
4) Use the library
Again, check the example: https://github.com/graphhopper/graphhopper/blob/master/android/app/src/main/java/com/graphhopper/android/MainActivity.java
As It's stated above, your application will need the xyx-gh directory with data.
Graphpoper initialization, you should do it on background
GraphHopper hopper = new GraphHopper().forMobile();
hopper.load("yourpathtodirectory-gh");
Usage, again preferably on background:
GHRequest ghRequest = new GHRequest(from, to);
GHResponse response = hopper.route(ghRequest);
For more information and more troubleshooting check the official documentation: https://github.com/graphhopper/graphhopper/blob/0.10/docs/index.md
Related
SOLVED
After having a lot of struggles here the fastest guide you'll ever find on how to setup a react native app with mongoDB realm. My thanks go to Joe who commented.
Setup the backend. Follow every step of the backend tutorial very carefully. IMPORTANT: In Step E5, use your own name for the app instead of the default. This name cannot be changed!
Setup your app with git clone --branch final https://github.com/mongodb-university/realm-tutorial-react-native.git. Therby you skip the whole frontend tutorial.
Remove the .git folder and rename the project root to complete your takeover.
Note that this example project contains backend functions and a lot of additional stuff on the frontend. Use those as cheat sheet for your implementations. Note that if you want to implement your backend functions using your IDE instead of in the online admincentral you need to do another import using realm-cli. Happy coding!
I'm trying to learn to write Hardware Abstraction Layer (HAL).
Here's the path I've taken so far, please correct me if I'm off in any step.
Downloaded AOSP and built it successfully (86%)
Located Vehicle Hal Support Library
Located android.hardware.automotive.vehicle C++ code.
Things I've attempted after that the steps below without succeeding to get those above classes recognized.
Import android.hardware.automotive.vehicle classes in Android Studio for a typical Android App that targets 29 Api Level.
Adding meta tag of android.car app
Copy/Pasting all source code under AOSP /packages/services/Car/
Partially contemplated adding android.hardware.automotive.vehicle#2.0.so Library and trying to access it through JNI (Not so sure about this one).
Please orient me, I see some repositories on github not doing anything special and somehow they're able to import the package in a java class like this.
import android.hardware.automotive.vehicle.V2_0.VehicleHwKeyInputAction;
import android.hardware.automotive.vehicle.V2_0.VehiclePropValue;
import android.hardware.automotive.vehicle.V2_0.VehicleProperty;
import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;
Here
how on earth do they get access to those classes?
Thanks
Vehicle HAL is not meant to be accessed directly from apps. Car Service does that for you.
You have couple options depending on what you're actually trying to accomplish:
Learn to write HAL services - it's like writing a driver for a given hardware (in this case, something that provides car data to Car Service).
Learn to write HAL clients - try modifying EmbeddedKitchenSink app first. Please note you need to build it with AOSP and not in AmdroidStudio since this is a system app (and regular apps doesn't have access to the HAL)
Learn Vehicle APIs - that's what you need car lib for. Details on how to use it: https://stackoverflow.com/a/63321234/14759774
I'm interested in using Hot Module Replacement with a newly created React app.
Facebook Incubator's create-react-app uses Webpack 2 which can be configured to support HMR, however in order to do so, one needs to "eject" the create-react-app project.
As the documentation points out, this is a "one way" operation and cannot be reversed.
If I'm to do this, I want to know what I might be giving up. I've been unable to locate any documentation that explains the potential drawbacks of ejecting.
The current configuration allows your project to get updates from create-react-app core team. Once you eject you no longer get this.
It's kind of like pulling in bootstrap css via CDN as opposed to downloading the source code and injecting it directly into your project.
If you want more control over your webpack, there are ways to configure/customize it without ejecting:
https://www.npmjs.com/package/custom-react-scripts
I want to use the Ionic UI framework with Trigger.io for my hybrid mobile app, but it isn't clear to me just how to combine the two in my code because it's not like using Jquery where you just add the library to a script tag.
After install, both of these frameworks provide their own "hello world" type of index.html file, their own css and js files as well as framework specific configuration files which I know are important. So which one do I use as a base and how do I call into the other framework from that base? How do I structure the project file tree to combine the two so that when I go to do an app build for distribution, there isn't some crazy error because the frameworks are set up to look for their own files via set paths?
Here is one answer I found in my googling.
What steps do I need to take to use the Ionic Framework with trigger.io?
here is an example project on git hub:
https://github.com/travisrussi/ionic-triggerio
here is the link to the ionic cdn to be used for testing:
https://code.ionicframework.com/#
I'm not an experienced Javascript application developer, however, I've recently been learning some MEAN using http://mean.io/#!/ as my scaffolding.
I can see that the out of the box assets are listed in:
/server/config/assets.json
and when the app is running the referenced assets get combined into client side files:
/modules/aggregated.css
/modules/aggregated.js
When I create a package using MEAN.IO's CLI:
mean package myPackage;
and start including css or scripts in this package, presumably it is bad practice to then put the packages assets into the application's assets.json as these packages are supposed to be reusable modules that could be added to someone else's MEAN application.
What's the right place to reference the new package's assets so that they are added into the aggregration process?
you want to add css or js files into your packages.
If so, it's easy. As the doc says in "Assets and Aggregation" http://learn.mean.io/#mean-packages-assets-and-aggregation
you should use
//Adding another library - global by default is false
MyPackage.aggregateAsset('js','jquery.min.js', {global:true});
//Adding some css to the mean project
MyPackage.aggregateAsset('css','default.css');