MapRouteFinder.GetDrivingRouteAsync and MapServiceToken in Windows Phone 8.1 XAML - c#

I have a Windows Phone 8.1 XAML app that uses the MapControl to display maps. In the MapControls Loaded event, I set a valid Bing API key
void MyMap_Loaded(object sender, RoutedEventArgs e)
{
MyMap.MapServiceToken = the key
MapService.ServiceToken = the key
}
I know the Bing API key is valid because the watermark in the MapControl is not shown.
From the page with the MapControl I navigate to another Page where in the ViewModel I try to find a driving route:
var driving = await MapRouteFinder.GetDrivingRouteAsync(new Geopoint(new BasicGeoposition
{
Latitude = Latitude,
Longitude = Longitude
}), Detail.GeneralInfo.GpsCoordinates.Position, MapRouteOptimization.Time);
The problem is that driving.Status is always InvaldiCredentials.
Is there something that I am missing?
The documentation says
Note that you have to provide the authentication token in two separate properties in an app that uses both Map services and the Map control.
and I did this.
The Bing API key I use is generated for Basic / Public Windows Phone App. I also tried to generate one for Basic / Public Windows App, no change.

I have a working app that uses this token. I only set it to a Map control in XAML, and then I can use both the Map and the MapService, apparently.
My Maps key token is 22 characters long. The only way to get it is, AFAIK
Make an app
Upload it to the store but do not submit
You app gets associated with a store ID and you will see a map token
THAT is the token you will need
See screenshot. Is that the procedure you followed?
Also, make sure xmlns:Maps="using:Windows.UI.Xaml.Controls.Maps", not the old Bing control. Don't even know if the old control is still available in the Universal Apps btw

Related

Open native maps in Windows phone 8 application on button click

Is there a way to open Bing maps that are inbuilt to Windows phone on click of a button. If you have used the Foresquare app, it loads bing maps and show the destination latitude and longitude when you click the directions button. I want to do the exact same thing. Please help me with any resource you have.
Until now I tried the code in this link
https://msdn.microsoft.com/library/windows/apps/jj710324%28v=vs.105%29.aspx
Problem is when I click the button it says do you want to search an app in the appstore. Please help.
You have to use BingMapsDirectionsTask like this (just replace latitude and longitude with yours):
BingMapsDirectionsTask bingMapsDirectionsTask = new BingMapsDirectionsTask();
GeoCoordinate spaceNeedleLocation = new GeoCoordinate(47.6204,-122.3493);
LabeledMapLocation spaceNeedleLML = new LabeledMapLocation("Space Needle", spaceNeedleLocation);
bingMapsDirectionsTask.End = spaceNeedleLML;
bingMapsDirectionsTask.Show();
You can reed more here about Bind Maps directions task.

change default pushpin from BingMapsTask class

I wonder if it is possible to open the bing map application after button click and send there my own .png icon for push pin. For now I can open the bing maps and I have a default pushpin, but I want to change that pushpin for my own.
This is my code for it:
var bingMapsTask = new BingMapsTask
{
SearchTerm = item.CoordinatesString
};
bingMapsTask.Show();
Thanks in advance.
You won't be able to modify the pushpin when using the Bing Maps Task as that opens up a separate app. If you want to be able to customize the map you will need to use the map SDK in WP.

Universal App On Phone - How to hide DisplayName?

When I run my Windows Universal App on my Windows 8.1 phone, the LiveTile has additional text (the name of my app) on it that I'm trying to hide. The text seems to be coming from the Package.appxmanifest
<m3:VisualElements DisplayName="This Text Appears" ...
I found a similar question (Is it possible to create a Windows Phone live tile where no title is displayed?) that suggests leaving the value empty. When I do this, Visual Studio complains that it is invalid and I'm not able to compile. Removing the DisplayName entirely also results in an error.
I can see other applications that do not show any text, so it does seem possible.
Can anyone tell me how to hide the DisplayText from my LiveTile, but still have the name of my app appear correctly on the list of installed apps on the phone?
The template I'm using for the live tile (TileWide310x150Image).
The DisplayName attribute inside the Package.appxmanifest file is required and cannot be left blank. It's also the name that will show in the Phone's list of installed Apps. You want that be the proper name of your app.
The name of the app will appear on the LiveTile and, in that context, it's called 'Branding'.
https://msdn.microsoft.com/en-us/library/windows/apps/br212854.aspx
<binding template = tileTemplateNameV2
fallback? = tileTemplateNameV1
lang? = string
baseUri? = anyURI
branding? = "none" | "logo" | "name"
addImageQuery? = boolean
contentId? = string >
It seems to default to 'name', but by setting it to 'none' the text will no longer be displayed on the live tile.
I was able to remove the Wide Tile Display Name in a Windows Phone 8.1 Runtime C# Application with the following code:
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150PeekImage04);
XmlNodeList brandAttribute = squareTileXml.GetElementsByTagName("binding");
((XmlElement)brandAttribute[0]).SetAttribute("branding", "none");
squareTileXml is the name of the XML being configured to the Live Tile while TileWide310x150PeekImage04 is the chosen template.
Basically I specified a tile template (documentation) and I changed the property branding, which is inside the binding in the XML tree, according to this documentation, to none, removing the Display Name.
I'm not sure if this is the right way of configuring that, but at least it worked.

different application bar in panorama windows phone for navigation

I am start developing application for Windows Phone 8.
As usual, there is something coming up. yups, that is error. LoL
I have an application using panorama, and I planning to put an appbar for each panorama item which will generate different appbar for different panorama item.
Luckily, I've found a tutorial about it. Here is the link :
http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh394036(v=vs.105).aspx
My problem is, how can I navigate to other windows phone page (known as xaml) from this App.cs??
Because when I start implement what I've known it bring me an error.
Any help and answer will be appreciated. ^_^
Thank you so much.
Regards,
Budi Prasetyo
"How can I pass a parameter from my mainpage.xaml or mainpage.cs, to app.cs? "
You can create a public property in your App.cs, something like:
public int ItemId {get; set;}
As the App context is available everywhere, you can access it via your MainPage.cs.
App.ItemId = your ID here

Hide Bing maps coordinates for the user

Is it possible to hide the Bing maps coordinates for the user ?
This is my javascript code:
var mapOptions = {
credentials : "My app code here",
zoom:#(Model.Sprint.ZoomFactor),
center:new Microsoft.Maps.Location(latitude, longitude),
showDashboard: false,
disableUserInput: true,
enableSearchLogo: false,
enableClickableLogo: false
};
In my html source, the coordinates become visible to the user but the user is not allowed to see where the exact location is.
Does anyone know how to hide them?
Im using ASP.net MVC 3 so the coordinates come from a viewmodel.
thanks.
As long as you are using the Bing maps javascript control, you cannot really hide this information from the user. The code is running on the user's machine, so how can you hide your source code and data from them? If your requirement is that the coordinates should not be visible in the downloaded source code, you can try something similar to the Bing interactive SDK, where they use an ajax call issued by the client to obtain the map license key at run time. But this is easily defeated by stepping through the code using the javascript debugging feature on your browser.

Categories