?
Solved

Drawing a line along a street in Bing maps

Posted on 2013-01-12
21
Medium Priority
?
552 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:Meir Rivkin
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
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!

 
LVL 42

Expert Comment

by:Meir Rivkin
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:
Meir Rivkin earned 1500 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:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
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:Meir Rivkin
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

807 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