Bing Maps API Web Control, Which directions are selected? - bing-maps

Using the bing maps API Web Control v8's DirectionsManager, how can I tell which directions have been selected if there are multiple routes displayed? Is there an event that I can't seem to find? Or maybe something that I can get from the directionsManager object?
Thanks!

Use the update event and the getCurrentRoute function:
Microsoft.Maps.Events.addHandler(directionsManager, 'directionsUpdated', function () {
var currentRoute = directionsManager.getCurrentRoute();
//This will be the currently displayed route. This will fire after a route calculation or when you select an alternate route option.
});

Related

Add url redirect to mapbox icon

I am trying to allow a mapbox marker to be clicked on and when clicked it automatically takes you to a new link.
Is this possible?
I currently have a map of 10 locations and when loaded the zoom level shows all. When you click on a location, it zooms you into that location.
I now want it to take you through to a url on the click rather than zoom in, however I cant seem to find any documentation on how to do it.
I am aware that it can be done using a popup box which contains a url in it, but is there a way to remove the extra step.
Thank you
You can use click event on your layer to get the feature clicked and use a property of your feature to build your link :
map.on('click', 'layername', function(e) {
// Here you can access e.features[0] which is the feature cliked
// With that you can do whatever you want with your feature
});
Sébastien Bousquet's answer work when using a Symbol, but if using a Marker, you'll need to add your your own click eventlistener like https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event.
marker.getElement().addEventListener('click', event => {
window.location.href = 'https://www.mapbox.com/';
});

How to get the geocode of a specific location by tapping on the map UWP C#

I went through lot of tutorials which states how to add a mapicon a pushpin on to a map, but all of them require me to hard code the latitude and the longitude or give the address in a text form.
But what i want is to get the geocode (lat and lon values) of any place when and where the user double tap on the map.
Adding a pushpin there is required too.
i am not using bing maps api, using services.maps, Devices.geolocation, map control and other uwp map functionalities only.
What you need to handle is the MapTapped of the MapControl event to get the geolocation of the place where the pointer is tapped. Something like this would do:
private void MyMap_MapTapped(Windows.UI.Xaml.Controls.Maps.MapControl sender, Windows.UI.Xaml.Controls.Maps.MapInputEventArgs args)
{
var tappedGeoPosition = args.Location.Position;
//Do something
}
Check out these official samples on GitHub

Windows Phone 7 - Bing Maps MVVM Pushpin initialization

Does anyone have a good guideline on how to initialize a pushpin on the Bing Maps control?
My current scenario works, but is not 100% correct... let me explain the details:
When I open the page with the Bing Maps control on it, I want the user to be able to push a small button that will show his current location.
To show the current location, I'm using a Pushpin. I'm already adding the Pushpin on the control in the XAML file like this:
<map:Pushpin> x:Name="currentLocation" Location="{Binding CurrentLocation}" Content="Me" ManipulationStarted="CurrentLocationPin_ManipulationStarted" </map:Pushpin>
Now with this scenario there a some problems!
One, the pushpin is always visible! So how do I go about this? ( I know I can bind the Visibility also to a property and use a bool to visibility converter, but is this the best way to do this? )
Secondly, now I don't initialize the Location in the viewmodel... but for semantic reasons I would love to initialize the default value to Geocoordinate.Unkown ( that way I can use this to do checks when the user tries to do some manipulation before a currentlocation is set ). But when I initialize the pushpin on startup I get following error: "UIElement.Arrange(finalRect) cannot be called with Infinite or NaN values in finalRect.". So my question again :) what is a good guideline to setting up a currentlocation pushpin? ( but do mind that the users has to push a small application bar button before the currentlocation is set )
The initialization problem is due to the visibility of the Pushpin. If the initial visibility of the Pushpin is Collapsed, then it won't take part in the arrange pass, so you won't get the error.
If you're using a view model to back this view, then I don't see a problem with exposing a property from the view model that determines whether the Pushpin should be visibile or not. Yes you could use a boolean to visibility converter, but you could save some processing by actually exposing a Visibility property (which is the approach I've used).
If you're using a command to initiate showing the Pushpin from the button push (the Silverlight Windows Phone Toolkit has a behavior to enable hooking up application bar buttons to commands).

jquery functions to get dynamic controls

I am added json object data and three buttons for every li tag in my webpage.
My requirement is , I want to get that dynamically added button . But i am not getting that button by using script below
$("but1").click(function(){
alert("hi iam getting dynamic added button");
});
So please give me some suggession to acheive this.
$('#selector').live('click', function(){} )
Since they don't exist, you need to use live or delegate
You need the live() method for dynamic generated elements:
$("#but1").live('click', function(){
alert("hi iam getting dynamic added button");
});
live()
Description: Attach a handler to the
event for all elements which match the
current selector, now or in the
future.

How do i get touch event on WebView

Hope you all are fine and also in one of your best moods!!
I have one problem in Map based application. kindly go through it and post your suggestion.
Thing at Glance:
I need to integrate map in my application.
application shows map based on passing parameter as state and city.
i am using yahoo map image for that.
i.e.
pass parameter as following:
state : CA
city : Loss Angelous.
it shows image of map perfectly that i load on webview.
now issue is here:
i need to put button at selected city.. i don't know how do i put.
because on clicking button i need to load another view that contains Details of that city.
I don't know how do i do this.
Kindly give your suggestion.
Thank you.
Arun Thakkar.
Using the iPhone SDK 3.0 you can use the MKMapKit framework to embed a map in your application, and you can add custom annotations. Here's the MKMapView documentation.