Solved

Drawing a line along a street in Bing maps

Posted on 2013-01-12
21
535 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now