开发者

add shapes to bing maps from locations stored in a database (bing maps ajax control)

开发者 https://www.devze.com 2022-12-22 21:06 出处:网络
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 a

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 excel开发者_如何学Golent 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 :(


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消