Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Drawing a line along a street in Bing maps

Posted on 2013-01-12
21
Medium Priority
?
548 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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 …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 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