Windows Phone get started
Nutiteq Maps SDK 3.1 supports also WP 8.1 apps.
Get Visual Studio extension package
Requirements:
- Windows 8.1
- MS Visual Studio 2013 Community edition, or better
- Windows Phone 8.1 SDK, should come with VS
- Visual Studio extension (VSIX) for Nutiteq Maps SDK component from Nutiteq SDK Downloads. Download and just start the package to install it.
Register license key
Sign up in developer.nutiteq.com and add an application. Select Windows Phone as application type, and make sure you enter same application ID as you have in your Package.appmanifest > Packaging > Package name. For example, sample app ID is c882d38a-5c09-4994-87f0-89875cdee539. Finally you should get license code, which is a long string starting with "XTU...". This is needed for your code.
Cross-platform apps
You can create one .Net project (solution) for Android, iOS, Windows Phone and share map-related code. These still need to be separate apps, as many app aspects (UI, file system etc) are platform-specific. From Nutiteq SDK point of view the API is almost the same and your code can be shared, except some specific API calls which need e.g. file system references or app resources.
Almost all of the map API related code: adding layers and objects to map, handling interactions/clicks etc can be shared for iOS and Android!
.Net sample project has two solutions: one for Windows Phone and another for Xamarin, and they share one project (hellomap-shared) with map-related code.
Creating WP app
1) Make sure you have Nutiteq VS extension installed, and your app project has Internet Capability as minimum. In Solution Explorer References section, add Nutiteq Maps SDK for Windows Phone. You should find it from Windows Phone 8.1 extensions. We don't have NuGet package yet, but it will come if you show us interest.
2) Copy vector style file (osmbright.zip) to your project Assets folder. You can take it from samples. This is needed for vector basemap.
3) Create MapView object, add a base layer
You can create MapView object with code. Definition of base layer is enough for minimal map configuration.
using Nutiteq.Core; using Nutiteq.Graphics; using Nutiteq.DataSources; using Nutiteq.Projections; using Nutiteq.Layers; using Nutiteq.Styles; using Nutiteq.VectorElements; ... protected async override void OnLaunched(LaunchActivatedEventArgs e) { if (mapView == null) { // Register Nutiteq app license var licenseOk = Nutiteq.Ui.MapView.RegisterLicense("YOUR_LICENSE_KEY"); // Create map view and initialize mapView = new Nutiteq.Ui.MapView(); // Online vector base layer var baseLayer = new NutiteqOnlineVectorTileLayer("osmbright.zip"); // Set online base layer. // Note: assuming here that Map is an outlet added to the controller. mapView.Layers.Add(baseLayer); } // Place the page in the current window and ensure that it is active. Windows.UI.Xaml.Window.Current.Content = mapView; Windows.UI.Xaml.Window.Current.Activate(); } private Nutiteq.Ui.MapView mapView; ...
Add a marker
To create a map Marker to given coordinates add following after creating mapView.
Note: You must have Icon.png in your Assets folder to set bitmap
// Create overlay layer for markers var proj = new EPSG3857(); var dataSource = new LocalVectorDataSource(proj); var overlayLayer = new VectorLayer(dataSource); mapView.Layers.Add(overlayLayer); // create Marker style var markersStyleBuilder = new MarkerStyleBuilder(); markersStyleBuilder.Size = 20; UnsignedCharVector iconBytes = AssetUtils.LoadBytes("Icon.png"); var bitmap = new Bitmap(iconBytes, true); markersStyleBuilder.Bitmap = bitmap; // Marker for London var marker = new Marker(proj.FromWgs84(new MapPos(-0.8164, 51.2383)), markersStyleBuilder.BuildStyle()); dataSource.Add(marker);
Other map actions
See hellomap3d-dotnet sample project (solution: hellomap-winphone.sln) how to:
- Control map view - set zoom, center, tilt etc
- Listen events (MapListener.cs) of clicks to map and map objects
- Add other objects: Lines, Polygons, Points, Balloons (callouts). You can even add 3D objects and use customized Balloons.
- Download offline map packages for country or smaller region
- See Guides pages with dotnet samples tab for other actions