views:

579

answers:

2

I am trying to use the Bing Maps Ajax Control to plot pins of locations stored in a database to the bing map on a web page. All the locations are geocoded and the lat longs stored in the database. I am using ASP.NET (C#), but can't figure out or find any tutorials on how to go about doing this. All I can find are articles on how to import shapes into a map from either GeoRSS, Bing Maps, and KML.

I have used (and paid for ;o) the excellent control from Simplovations to do alot of what I need to do, namely working with my data as normal in the code behind, getting a DataSet of my locations and plotting the points to the map. It has been great, but I want to know how to do it with out using a third party control. My main reason for wanting this is to be able to cluster my pins and hopefully learn a bit of Javascript along the way.

Does anyone know how to do this or can point me to any tutorials or articles online that can help me on my way. I have been searching the net for days now and can't find anything :(

+1  A: 

I don't know if this is the preferred way of doing it, but I would suggest that you load the coordinates from the database into hidden fields onto the page. In the JavaScript on the page you can create VELatLong coordinates for each pin/shape you want loaded on the map. Here I used jQuery to load the values.

In the JavaScript

var latitude = $("#Latitude").val();
var longitude = $("#Longitude").val();

latLon = new VELatLong(latitude, longitude);

On the Page

<input id="Longitude" name="Longitude" type="hidden" value="-80.98271369934085" />
<input id="Latitude" name="Latitude" type="hidden" value="43.371240452765925" />

For more then a since pin you would want to use an array and then load the shapes in a loop.

I hope this helps you out.

Lukasz
Thanks Lukasz, I sort of arrived at the solution you have pointed out. It's not my preferred choice but it's working. I have since moved onto the SilverLight control as a better solution. It certainly looks and renders better and coming from a C# background is nicer (for me) to work with. Thanks again for taking the time to respond.
macou
A: 

I commonly utilize a web service and ajax methods to pull down the pins at runtime. SoulSolutions has an interesting clustering algorithm and example web service you can find here:

http://soulsolutions.com.au/Blog/tabid/73/EntryId/8/Clustering-a-million-points-on-Virtual-Earth-using-AJAX-and-Net.aspx

Peter Smith