Solved

Drawing a line along a street in Bing maps

Posted on 2013-01-12
21
540 Views
Last Modified: 2014-11-12
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
0
Comment
Question by:Dodsworth
  • 11
  • 10
21 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 38771508
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.
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38777368
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
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38777437
Found it..

Imports Microsoft.Phone.Controls.Maps


Now which namespace does Location come from?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 42

Expert Comment

by:sedgwick
ID: 38777446
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
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38778031
That link VB'ified would do perfectly.. go for it :)
0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 38778147
basically you use MapPolyline object.
something like:

dim lines as MapPolyline = new MapPolyline()
lines.Stroke = new SolidColorBrush(Colors.Blue)
lines.StrokeThickness = 5
lines.Opacity = 0.7
lines.Locations = new LocationCollection()
lines.Locations.Add(new Location(from_latitude, from_longitude))) 
lines.Locations.Add(new Location(to_latitude, to_longitude))) 
MyMap.Children.Add(lines);

Open in new window


from_latitude, from_longitude and to_latitude, to_longitude are the coordinates of the beginning and end of the line.
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38778310
is it possible to VB'ize the project that you linked ?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38778638
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
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38779077
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 ?
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38779157
Unless you use silverlight to code your mobile app theres no reason using this sdk.
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38779260
oh.. I read.."Silverlight is the primary development environment for Windows Phone" in wiki?  

sorry for being so nooby
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38779606
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.
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38781806
added system.device.location but still errors on Location
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38781829
which SDK did you download and use?
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38782302
I didn't, just downloaded VS2010E for WP
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38782400
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.
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38788303
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 :)
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38788816
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.
0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38792100
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 ;)
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38792657
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
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38792664
In regards to hit/click polyline coords, open new thread and post here the url and ill do my best to assist you.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question