I have a WP81 (Silverlight) that uses a GPS geofence background task. I want the user to select the location on where to create the geofence. For this, I currently provide two textboxes for Longitude and Latitude values of a geo coordinate. While this works fine, I guess users will be irritated because the expected behavior would be to provide an address or directly set a point on a map.
In order to provide a map where the user can select a given location I was searching for something like a chooser or launcher. The only launcher that I found is the MapsTask. Unfortunately, it is not possible to let the user select some location and get the geocoordinate back.
private void btnLaunchMapsTask_Click(object sender, RoutedEventArgs e)
{
MapsTask mapsTask = new Maps-Task();
mapsTask.Center = new GeoCoordinate(51.5171, -0.1362); // London
mapsTask.Show();
}
As you can see I can just open the map and provide a specific geocoordinate where to center the map.
Is there a way in Windows Phone 8.1 (Silverlight) to provide a user with a map to select a location and get the geo coordinate back? Is it possible via MapsTask and I just don't see it? Is there another way (even 3rd party package on NuGet) to achieve this?
You could use the SearchTerm property to solve this. Sample:
MapsTask maps = new MapsTask();
maps.ZoomLevel = 9;
maps.SearchTerm = "London";
maps.Show();
Related
https://learn.microsoft.com/en-us/bingmaps/v8-web-control/map-control-concepts/pushpins/pushpin-events-example
If I'm trying to make an app on C# using Bing Maps API, is it possible to have pushpin events like in the link above? Some sample code I found lets me put a pushpin like thisenter image description here
This is the section of code that created 4 pushpins(only 2 visible in the picture).
var r = new ImageryRequest()
{
CenterPoint = new Coordinate(coord1, coord2),
ZoomLevel = 5,
ImagerySet = ImageryType.RoadOnDemand,
Pushpins = new List<ImageryPushpin>(){
new ImageryPushpin(){
Location = new Coordinate(45, -120.01),
Label = "hi"
},
new ImageryPushpin(){
Location = new Coordinate(0, 1),
IconStyle = 3
},
new ImageryPushpin(){
Location = new Coordinate(coord1, coord2),
IconStyle = 20
},
new ImageryPushpin(){
Location = new Coordinate(33, -75),
IconStyle = 24
}
},
BingMapsKey = BingMapsKey,
};
It looks like you are using the BingMapsRestToolkit that provides a c# API for accessing the Bing Maps REST services. In particular, you are calling the static imagery service which returns an image, not an interactive map. If you wanted to write some code so that someone could click on a pushpin in the image and you would know it, there would be a decent amount of math involved. It can be done, but you might be better to first consider using an interactive map SDK in your app instead as that would provide a lot more capabilities that would allow the user to interact with the map. Bing Maps has two interactive map SDKs that you can develop with using C#.
There is the Windows UWP map SDK that can be used in Windows apps, and in WPF apps via a XAML island. Here are some useful resources:
https://learn.microsoft.com/en-us/windows/uwp/maps-and-location/
https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/host-standard-control-with-xaml-islands
There is also an older WPF SDK that has fewer capabilities than the UWP SDK. It is generally recommended to use the UWP map control, but if you want to use this, here are the details: https://learn.microsoft.com/en-us/previous-versions/bing/wpf-control/hh750210(v%3dmsdn.10)
I have a problem finding a way to show the coordinates from a c# file as pins in bing maps.
I wrote this :
var map = (FastFood.Grill)grill.SelectedItem;
var map2 = (FastFood.Grill)grill.SelectedItem;
BingMapsTask loc = new BingMapsTask();
loc.Center = new GeoCoordinate(map.Map, map2.Map2);
loc.Show();
Map is latitude and Map2 is longitude and I use the BingMapsTask and unite both of them on a single object, loc, and then I see the desired outcome/place on Bing Maps without making a new page with a map inside and writing more code. I want a way to make the shown location being shown with a pin.
Thanks!
I am trying to use a string that has a location(i.e. a book store read from an xml file) and then gives you directions from your current location to reach that particular book store. I am unsure as to how to do this. I believe it requires bing maps, but I am wondering if anyone has any code that performs a similar operation. Maybe you need specific coordinate points to be read in from the XML file? Thank you for your time and help!
You can rely on BingMapsDirectionsTask to accomplish that easily. Following is an example on how to show direction from current location to a book store location :
var directionTask = new BingMapsDirectionsTask();
var bookStoreCoordinate = new GeoCoordinate(Double.Parse(latitudeStringFromXml, CultureInfo.InvariantCulture),
Double.Parse(longitudeStringFromXml, CultureInfo.InvariantCulture)));
directionTask.End = new LabeledMapLocation("book store name", bookStoreCoordinate);
directionTask.Show();
You can search with keyword "windows phone 7 BingMapsDirectionsTask" to get further information.
I know this question as been beaten to death, but I don't want anything super complicated here.
We have a companion app with our site that is only compatible with 7 and 10-inch tablets. We need to only alert users on those devices about our app. Problem is, I can't go by resolution. My Galaxy S3 has a 1280 x 720 screen, but is obviously not a tablet. I also can't for the life of me find out a way to get the physical size of the screen. The only solution I have come up with is detecting whether the device can make calls with MobileCapabilities.CanInitiateVoiceCall. Unfortuantely, by boss isn't happy with that solution.
So... How can I distinguish between a phone and a tablet in my web app (Server or client side)?
UPDATE: So far it seems that the best approach for Android is something from a blog post by the Android team: All Android phones use "Mobile" in the UserAgent string, so checking for "Mobile" *and "Android" will tell you if it's a phone, while just "Android" should be a tablet. iOS devices should be just as simple--checking for "iPhone" vs "iPad" seems to have worked so far.
I know this is a little late, but I was looking for the same thing.
Wurfl has wat you want. You can implement it easily and and even have an api you can query.
For ASP.NET application first you must place the one-off initialization.
public class Global : HttpApplication
{
public const String WurflDataFilePath = "~/App_Data/wurfl.zip";
private void Application_Start(Object sender, EventArgs e)
{
var wurflDataFile = HttpContext.Current.Server.MapPath(WurflDataFilePath);
var configurer = new InMemoryConfigurer().MainFile(wurflDataFile);
var manager = WURFLManagerBuilder.Build(configurer);
HttpContext.Current.Cache[WurflManagerCacheKey] = manager;
}
}
And then use it like this.
var device = WURFLManagerBuilder.Instance.GetDeviceForRequest(userAgent);
var isTablet = device.GetCapability("is_tablet");
var isSmartphone = device.GetCapability("is_smartphone");
For more info check ASP.NET implementation
Hope this helps anyone else looking for this.
You can try to do a user agent detection and search for the keywrords, for example, all Non tablet devices have a "Mobile Safari" key words on their user agent.
In Windows Phone (mango) I am using Microsoft.Phone.Controls.Maps.
I currently have:
var _City = "Denver";
var _State = "Colorado";
And I want a pushpin:
var _Pushpin = new Pushpin();
_Pushpin.Location = new GeoCoordinate();
map1.Children.Add(_Pushpin);
map1.Center = _Pushpin.Location;
How can I create the correct GeoCoordinate from the strings alone?
Update with solution (using Bing):
http://blog.jerrynixon.com/2011/10/bing-maps-geocoding.html
There are a couple of ways...
1) Get a Bing Maps API key and call into their web services to get the coordinates. (see here for an example)
2) Have a local database of cities / states / coordinates to look up against. This is probably the preferred option if the app must run offline, although in that case you wouldn't see the maps anyway.