I am trying to save route using SkRouteManager's saveroutetocache, and showing route using loadroutefromcache but actually the route is not being saved so every time I load it from the stored id, it shows the route cannot be calculated.
Is there any way to save the route not just in the current map view?
Check out the dedicated chapter for route caching/loading in the documentation and also see the implementation in the demo project (you will have to make sure that "provideMultipleMapSupport" is true in the demo project's manifest for the multiple map views code to be active - see this for details)
Related
Is there a way to get the remaining route or coordinates from the current navigation route while driving? I am using HERE SDK for Android (Premium Edition) 3.15. Example: If the whole route is 100% and I've driven 20%, I would like to get the remaining 80% of the route/coordinates.
PS: If I can get the next waypoint that I need to pass through would also be helpful.
VenueNavigationManager and FTCRNavigationManager(in beta) provides methods that can get the distance travelled, also the method that returns the remaining time and distance. Including the API references for the premium Android Edition :
https://developer.here.com/documentation/android-premium/3.16/api_reference_java/index.html?com%2Fhere%2Fandroid%2Fmpa%2Fvenues3d%2FVenueNavigationManager.html
&
https://developer.here.com/documentation/android-premium/3.16/api_reference_java/index.html?com%2Fhere%2Fandroid%2Fmpa%2Fftcr%2FFTCRNavigationManager.html
I'm creating an Android app using MapBox. I've already set up a simple map functionality with markers sourced from .json file. Next step is filtering the markers on the map, just like in this gl-js example here:
https://docs.mapbox.com/mapbox-gl-js/example/filter-markers/
I can't find any sdk examples anywhere, and since this is my first app I really can't figure it out on my own. Any help will be appreciated.
You can check out this example https://docs.mapbox.com/android/maps/examples/multiple-expressions-temperature-change/ that features two layers that fetch a min or max temperature from the data source and display it.
The filtering part is done here:
// Only display Maximum Temperature in this layer
maxTempLayer.setFilter(eq(get("element"), literal("All-Time Maximum Temperature")));
loadedMapStyle.addLayer(maxTempLayer);
Filters accept expressions as arguments, and here Expression.eq is used to compare "element" from the GeoJSON data source (referenced with the Expression.get) with the "All-Time Maximum Temperature" value. If it resolves to true, the feature is going to be displayed, otherwise, it's going to be hidden.
I am using Here Map Android SDK. Currently my app can calculate the initial route and draw it through NavigationManager. Listeners are implemented and it will recalculate/redraw when the position changes, but I have a moving target: the destination is another vehicle position I get from a web service at 30 second intervals.
What is the proper way to have the route adjusted for a change in destination?
The easy way is to create a new route with an updated destination waypoint, have it calculated, then replace the old route and its listeners with the new one. I fear this wastes computing resources and produces lag/flicker on the map during the redraw. If this is indeed the path to take, how do we minimize screen issues?
I tried just changing the coordinates of the waypoint but it has no impact. I searched for a "route waypoint change" listener, similar to a traffic or position listener but could not find any.
Update: Since Here confirmed a route destination cannot be updated, I clarify my request for "howto":
What objects can I reuse in the new one? Which objects must we remove from the map and/or destroy to avoid leaks?
Initial plan:
keep handle on waypoint, original route (missing any?)
modify the destination waypoint coordinates
create a new route and have it calculated
move the destination map marker to the new destination
add new route
remove the original route (I assume the beginning of the route is similar in most update cases, so we avoid "flicker")
Anything missing? Listeners handling?
Here SDK does not provide such feature as of today. You can not change existing route or update its target. If you have new destination point you should calculate new route.
I have big KML file to a native Android application, please check the following details and give an advice.
KML file details:
size: 1.7 MB
total number of kml file elements: 500 elements
total number of polygon: 1000 polygon
Android app details:
the above details will be viewed in Fragment
I used the following support library to implement this screen
compile 'com.google.maps.android:android-maps-utils:0.4+'
some caluctations are done on loading the screens(like distance calculations)
Issue:
Take a lot of time to load the map and kml layer about 8 sec
create KMLLayer instance
What is the best practice to implement the above details with good performance?
please advise.
Best practice is doing long time operation in background (for example, on separate thread) and split complex tasks into small parts. So you can:
1) create and start load KML layer as soon as possible (e.g. on app create) and than just show it;
2) instead of one kml file with 500 elements and 1000 polygons, use 50 kml files with 10 elements and 100 polygons and load to layer only necessary files (for example you can split it by area location, or by semantic information, or by something else criteria);
3) combine 1 and 2 points;
4) precisely for google maps it's possible to create tiles with information from kml files and use TileProvider.
Since there's no actual answer, I'll post my own solution.
I've done mainly two things to optimize this.
Instead of using Google maps utils built-in method addLayerToMap - I've used my own custom implementation. I've done so, because parsing kml is relatively fast(in my case - ~5-10 seconds) and it can be done in background thread. Adding all the points to the map, however, takes more than 10 seconds, and must be done on UI thread. Basically, I've used KmlLayer class as a base, and parsed kml file by myself into polygonOptions and all other things I need.
Calculate which items are visible and which are not. Firstly, I filter which items are outside screen bounds. After that, I calculate each item's size(in pixels, no meters) - if item is smaller than threshold - item is also filtered out.
With these hacks applied, instead of freezing app for 15 seconds, user can freely navigate through map, and when he stops, after several seconds information will be displayed.
I just make some updates on the screen behavior to get good performance and good user experience by the following steps:
Divide the KML File to 65 files (the main areas on the map, for example, Zone A11 is located in one KML file and it contains all its details like Zone A11-1, Zone A11-2 and Zone A11-4 ...) and this division is done to be suitable the screen experience (for example user requirements)
on the first load, I am loading only the markers for all KMLs centers and that is not affecting the performance
When user click on the marker, I am loading the KML file for this area and zoom this area
When user zoom out, I am removing this layer from the map and load marker
When user moves the map I am calculating the nearest marker and load its KML layer
Note: preparing files on app launching will not provide better performance because the bad performance comes from adding the KML layer to the google map
Note2: using custom implementation for parsing and adding to Google map take a lot of time or need a lot of unit testing, and I think it's not recommended solution because it's better to leave this solution to be on Google Map utils build-in method (it's customized and always up to date)
I'd suggest you to make sure that you are constructing the KmlLayer on a background thread and addLayerToMap() has to be done on the main thread though like this
GlobalScope.launch {
val stringUrl: String = "https://saltwx.com/bath/SW_bath6.kml"
val inputStream: InputStream = URL(stringUrl).openStream()
val layer = KmlLayer(map,inputStream, applicationContext)
runOnUiThread {
try {
layer.addLayerToMap()
} catch (e: Exception) {
e.printStackTrace()
}
}}
I use here-map sdk. I have db file with 16500 ! paths (coordinates of a point). I need to draw all paths on the map, when user activate function "show additional paths". But i think, if i try to fetch big number of path and add all poplilynes object on here map, it will take a huge amount of time.
Help to find the optimal solution.
I would filter your data based on the visible viewport and disable this functionality where it doesn't make much sense (continental or globe level).
So, let's assume you app shows the map on zoomlevel 16 or 17 (district level), you can retrieve the viewport as GeoBoundingBox from the Map instance (e.g. via mapView.getMap()) with getBoundingBox().
The GeoBoundingBox makes it easy for you now to check for collisions with your own objects, since it has several "contains()" methods.
So everything that collides with your viewport should be shown, everything else is ignored.
You can update whenever the map viewport changes with either listening for OnTransformListener in the Map class or register for the MapGesture events (get MapGesture via getMapGesture() and listen for zooming events via addOnGestureListener())
If the amount of data for filtering is still too big, you can also think about preparing your data for more efficient filtering, like partitioning (region based would be my first idea) so only a subset of your data needs to be filtered.
It seems that Custom Location Extension (https://developer.here.com/platform-extensions/documentation/custom-location/topics/what-is.html) can help with this case.
In short, it allows you to upload a custom data to the HERE backend and query it later.