installMapPackages of Current city - here-api

I read this doc
https://developer.here.com/mobile-sdks/documentation/ios-premium/topics/maps-offline.html
installMapPackages. ---> It is installing all map But I need to install map particular city How to use this code for particular city.
NMAMapPackage* root = self.mapLoader.rootPackage;
Ex- I am from India I need to download particular city map. Than How to download the particular city map.
-(void)startInstall
{
NMAMapPackage* root = self.mapLoader.rootPackage;
[self refreshMapPackageTableWithArray:(NSMutableArray*)root.children];
}
- (void)refreshMapPackageTableWithArray:(NSMutableArray*)mapPackages
{
self.currentPackages = mapPackages;
NSArray *packageArray = [[NSArray alloc]
initWithObjects: self.currentPackages, nil];
[[NMAMapLoader sharedMapLoader]installMapPackages:packageArray];
}

In the code, you are downloading the root map package which contains the entire world. NMAMapPackage is represented as a tree structure, so you have to search the package structure recursively to find the MapPackage you would like to install. You can do this using the children property of NMAMapPackage and looking at the title of the children.
Please see the links below for more info.
You can find an example app for map downloading on GitHub: Map Downloader iOS
Similar Question on Stack Overflow: HERE API Offline Maps
User Guide: Offline Maps (MapLoader)
API Reference: NMAMapPackage
API Reference: NMAMapLoader

Related

Here SDK flutter does not show places image. Always returns no data for images

I am new to "Here" and I am using Here SDK Flutter 4.3.3.0. I want to fetch/search for places and get the Place's Photos/Image and or Place's Logo if the place is a business/company.
The place images place.details.internalimages are always empty when I search for any place. I tried for different countries like "Chipotle" a restaurant near Las Vegas, a restaurant in Canda, and a Shopping mall in India. All of these return 0 (zero) images. Does, Here API support to get places photos like Google Places or TomTom API?
Looks like this API has a method to get WebImage List but does not contain any data at all. Please advise, If I need to use any other method to get Place's photos.
Another question is, is there a way to get a company logo, if the place I am searching for is a business/company like Restaurant, Store, etc.
Below is the code, I use in my Flutter application. Note, I am able to get other field values like title, address, etc.
TextQuery textQuery = TextQuery.withAreaCenterInCountries('some partial place name', geoCoordinates, countryCodes);
searchEngine.suggest(textQuery, searchOptions, onHereSearchSuggestionCompleted);
In onHereSearchSuggestionCompleted functions, I have the following code:
if(suggestions.length > 0){
print('explore - onHereSearchSuggestionCompleted - suggestions count > 0');
for (Suggestion suggestion in suggestions) {
print('onHereSearchSuggestionCompleted - current count = ${(suggestions.indexOf(suggestion) + 1)}');
print('onHereSearchSuggestionCompleted - suggestion title = ${suggestion.title}');
print('onHereSearchSuggestionCompleted - place id = ${suggestion.place.id}');
print('onHereSearchSuggestionCompleted - place title = ${suggestion.place.title}');
print('onHereSearchSuggestionCompleted - place address = ${suggestion.place.address.addressText}');
print('onHereSearchSuggestionCompleted - place img length = ${suggestion.place.details.internalimages.length}');
}
}
Please note, you have been able to see this functionality being exposed in flutter SDK due to a bug exposing internal methods in flutter. In general this functionality is not yet public (not in native android and iOS).
We plan to expose this functionality soon, however even when we do, only certain eligible customers would have access to the image content. There should be contractual agreement to be able to see this functionality

Access Here XYZ Studio Map GeoJSON via API?

I'm wondering if there's a way to build a map in Here XYZ Studio but then get said map's GeoJSON via one of the Here APIs.
HERE Maps API for Javascript can render your XYZ Studio spaces directly:
// Assumption: the platform is instantiated
var service = platform.getXYZService({
token: 'authentication_token_goes_here'
}),
provider = new H.service.xyz.Provider(service, 'space_id_goes_here');
map.addLayer(new H.map.layer.TileLayer(provider));
doc: https://developer.here.com/documentation/maps/3.1.14.0/api_reference/H.service.xyz.Provider.html
It also can render geojson features:
var reader = new H.data.geojson.Reader('/path/to/geojson/file.json');
reader.parse();
// Assumption: map already exists
map.addLayer(reader.getLayer());
doc: https://developer.here.com/documentation/maps/3.1.14.0/api_reference/H.data.geojson.Reader.html
Here is simple jsfiddle example of loading geojson features (country shapes):
https://jsfiddle.net/vhwfg8t4/

Xamarin Forms Maps Geocoder Not Working on UWP Device

My app uses Xamarin.Forms.Maps to display a map and also for geocoding. The map is displayed on a separate page when the user navigates to it from the main page. I use the geocoder to reverse geocode the current location so that I have the address. This is done from various places other than the map page.
When I run the app on a device (even in debug mode) the geocoder works right away in iOS and Android, but does not work in UWP. After I navigate to the map page and display the map, then go back to a different page to use the geocoder it starts working.
I saw a thread about the map not working with release build so I added the following code:
var laRendererAssemblies = new[] { typeof(Xamarin.Forms.Maps.UWP.MapRenderer).GetTypeInfo().Assembly };
Xamarin.Forms.Forms.Init(e, laRendererAssemblies);
//Xamarin.Forms.Forms.Init(e);
Xamarin.FormsMaps.Init("MyBingMapsKey");
This has not helped the issue with the Xamarin.Forms.Maps.Geocoder. I also tried creating an instance of Xamarin.Forms.Maps.Map in my main page, but that did not help either. Is there a way to prime the map component so that the Geocoder will work on a device? (My test device is ARM, but it happens when I run on Local
Machine (Win 10) too)
Following is a snippet of the call to the Geocoder (which works fine once the user has navigated to the Map page and back - and it works fine in iOS and Android - and as such I don't believe it is a problem with the code, but here it is):
public static async Task<Plugin.Geolocator.Abstractions.Position> Geocode(string address)
{
try
{
var loGeocoder = new Xamarin.Forms.Maps.Geocoder();
System.Diagnostics.Debug.WriteLine("Get Lat/Lon");
var lcolPositions = await loGeocoder.GetPositionsForAddressAsync(address);
if (lcolPositions != null)
After doing some research and ensuring that your geodecode class being static wouldn't mess with the async/await pattern in the UWP build. I've come across a few references to this particular problem with the built in Forms.Map geodecoder elsewhere, not just for UWP it has also been noted for android‡.
I took some time to have a look at one of our current cross-platform applications that we have in the app stores, and according to our internal documentation we switched out both the xamarin.forms map, and the geodecoder for custom ones.
The plugin that we use for our cross-platform application is the 'GelocatorPlugin' created by james montemagno, and can be found here.
It can be added to your project as a Nuget package if you prefer, and the implementation of it is very similar to the default one, so there's very little code to change. The primary benefit is that the UWP element of the geodecode plugin has been modified to take into account windows advanced tracking scenarios (details found here).
It should be a lot more stable than the one your using, once installed you simply use it like so:
Reverse Geocoding
Based on a location that is passed in, thi swill grab a list of
addresses.
UWP requires a Bing Map Key, which you can acquire by reading this
piece of documentation.
try
{
var addresses = await locator.GetAddressesForPositionAsync (position, string mapKey = null);
var address = addresses.FirstOrDefault();
if(address == null)
Console.WriteLine ("No address found for position.");
else
Console.WriteLine ("Addresss: {0} {1} {2}", address.Thoroughfare, address.Locality, address.Country);
}
catch(Exception ex)
{
Debug.WriteLine("Unable to get address: " + ex);
}
‡ Links to similar problems - Link 1, Link 2
resolved after added following lines in APP.xaml.cs (UWP project)
Xamarin.FormsMaps.Init("bingmapkey");
Windows.Services.Maps.MapService.ServiceToken = "bingmapkey";

Store Locator API + Geolocation

I am trying to create a Store Locator with the Google API, very similar to the one in the Google examples here:
http://storelocator.googlecode.com/git/examples/panel.html
However I've hit a wall trying to get the Store Locator API to get the user's position through Geolocation, so when I click on Get Direction in the infowindow I get directions to the user position; instead of having to type my address in the: Where are you? Panel box.
In the documentation what I have seen is that geolocation is a boolean in the View Option that is set to True by default. But this does not solve my problem.
Does anyone have any idea on how to do this?
seems that the googlecode page you said is no longer exist. So I can't give any further insight about what you want to make.
However, by your description, Luckily I made similar site few months ago. It is on Grocery Store Near Me .
The concept of Geolocation is an HTML5 (actually W3C) Geolocation API which is now already embed in most modern browser. It is an API which you can obtain user's location (latitude, longitude, altitude, and accuracy).
you can call it with simply
navigator.geolocation.getCurrentPosition(success, error, geo_options);
Success and error is a callback function in which you can define.
In my case, the function looks like these
function success(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
// use the lat and long to call function to fetch an API through AJAX
fetchStoreData(latitude, longitude);
}
In the Store Locator schema (like mine in Grocery Store Near Me), Geolocation is used to obtains user lat and long. The lat and long, then send to server via AJAX to get data about nearby store location.
The server serve an API in which accept lat and long as parameter, then fetch the store data (either using database, or other external API like foursquare), then you can display it either on list, or on a maps.

Mono for Droid: how to plot route

I am working on Mono for Android App and want to show a route map between two points. I implemented their Xamarin.Android Map API to get the current location.
I couldn't get how to plot a route from current location to destination. Is there any library or framework?
Xamarin.Android Map API is based on Google Maps Android v1 API which is deprecated as of December 3rd, 2012. If you really, really want to implement Google Maps I would recommend looking at the Xamarin Maps and Location Demo v2 which uses Google Maps Android v2 API. However drawing a route is still not an easy task - you can use the Google Direction API to obtain a polyline and use it to draw a shape on the map as described here (BTW notice the limitations of Direction API free usage).
I suggest a different approach. If your ok with using Open Street Maps I would definitely go for OSM Droid library along with OSM Bonus Pack which does all the magic for you. Take a look at Xamarin OSM Droid Binding sample. To include the Bonus Pack you can add its JAR to the Osm Droid Binding solution and fix two visibility issues by adding to Metadata.xml:
<attr path="/api/package[#name='org.osmdroid.bonuspack.routing']/class[#name='RoadLink']" name="visibility">public</attr>
<attr path="/api/package[#name='org.osmdroid.bonuspack.overlays']/class[#name='MapEventsOverlay']/method[#name='draw']" name="visibility">public</attr>
Having this set up there is a very nice Road Manager that will plot a route for us. Below is a sample code snippet:
public class MainActivity : Activity
{
private IMapController _mapController;
private MapView _mapView;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
_mapView = FindViewById<MapView>(Resource.Id.mapview);
_mapView.SetTileSource(TileSourceFactory.DefaultTileSource);
_mapView.SetMultiTouchControls(true);
_mapController = _mapView.Controller;
RoadManager roadManager = new MapQuestRoadManager();
JavaList<GeoPoint> waypoints = new JavaList<GeoPoint>();
waypoints.Add(new GeoPoint(51.776625, 19.454834)); //start point
waypoints.Add(new GeoPoint(51.770839, 19.464962)); //end point
Road road = roadManager.GetRoad(waypoints);
PathOverlay roadOverlay = RoadManager.BuildRoadOverlay(road, _mapView.Context);
_mapView.Overlays.Add(roadOverlay);
_mapView.Invalidate();
}
}
More tutorials on this topic are located here.

Resources