Link to home
Start Free TrialLog in
Avatar of Dodsworth
Dodsworth

asked on

Drawing a line along a street in Bing maps

Hello

I'd like to find a way to draw a line along a street in Bing Maps based on data from location services.

I have code to get the current location.  Is there anything in Bing Maps that would allow me to plot my progress on a map ?

Many Thanks
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

here's an example of adding line to your map based on 2 locations:

Dim  polyline as MapPolyline= new MapPolyline()

polyline.Stroke = stroke
polyline.StrokeThickness = strokeThinkness
polyline.Opacity = opacity
polyline.Locations = New LocationCollection() With { _
	New Location(-20, 20), _
	New Location(-20, -20) _
}
MyMap.Children.Add(polyline)

Open in new window


now, change the Location coordinates with your street coordinates.
Avatar of Dodsworth
Dodsworth

ASKER

This looks promising only...

I get MapPolyline is undefined.

The Windows 7 Phone Training Kit says that I need a reference to Microsoft.Phone.Controls.Maps.

Bing Maps Silverlight Control API Reference on MSDN says that I should reference Microsoft.Maps.Mapcontrol?

I have neither of these namespaces listed :(

I'm working with Visual Studio 2010 Express For Windows Phone in VB.net using the Map control from the toolbox.

Can you tell me what reference to add and where I get it from please ?

Thanks
Found it..

Imports Microsoft.Phone.Controls.Maps


Now which namespace does Location come from?
the namespace is: System.Device.Location.

btw, check this post, it relate to windows phone 7:
Windows Phone 7 With Location Services And Bing Maps
 
if you need help converting the code to vb.net i'll be glad to do it for you.

cheers
That link VB'ified would do perfectly.. go for it :)
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
is it possible to VB'ize the project that you linked ?
i didn't see a link to the whole project, also this is used as example of silverlight control which is not your environment.

anyway, if you have the map and locations, then creating the MapPolyline should be easy for you now that you have the code.

here's some .Net code which describe Bing Maps in win phone:

if you need help converting it to vb.net, i'm here for you.

cheers
now i'm really confused.

I used the Silverlight / XNA Project template thinking that that was the way to go as with the examples.  Can I use the map control in a standard winphone app ?  What is the difference ?
Unless you use silverlight to code your mobile app theres no reason using this sdk.
oh.. I read.."Silverlight is the primary development environment for Windows Phone" in wiki?  

sorry for being so nooby
you said you code with Visual Studio 2010 Express For Windows Phone in VB.net.
so you are not binded to silveright in anyway.
you can download and work with any sdk which is supported by windows phone.
added system.device.location but still errors on Location
which SDK did you download and use?
I didn't, just downloaded VS2010E for WP
are you planning to build mobile, web or map application?

choose here:
Bing Maps

download the SDK and start coding, whatever you use is fine really.
Fixed it..

Location is GeoCoordinate in my VS version.

All is good :)


Do you have any experience of clicking/hit testing polylines ?  If so I'll open a new topic :)
No problem bro but why grade B?
I literaly coded the solution for you.
Its not like you loose something by grading me A.
And id have helping you with additional stuff without open new question.
Sorry for the B.  

You did spend a lot of time on my question.  

I just thought an A would be a first shot problem solve.

Must try to be less harsh in future ;)
you dont have to sorry just wanted to know what was the reason. For the recotd, despite being vague in some cases, A graded when complete solution to the question was provided eiyher by code/answer or direct link without the need of changing too much stuff.
I belive that i provided one and if not please tell me and ill help you till its gonna work as expected.
Cheets
In regards to hit/click polyline coords, open new thread and post here the url and ill do my best to assist you.