I have a table containing multiple addresses, including their Lat/Long coordinates, and I want to place many of these markers onto a google map at once, using asp.net webforms and Google Maps Javascript API V3.
The tutorials show how to add one marker:
http://code.google.com/apis/maps/documentation/javascript/overlays.html#Markers
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var myOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title:"Hello World!"
});
My question is, after I've loaded the set of multiple addresses server side (codebehind), what is a good way to output this set into the html such that client side javascript can iterate the collection and place markers onto the map.
Update
If I already had created my set, what would be a decent way of pushing that out into the page's html at render time, without calling an external script? (Passing the complex filter parameters to the script would be complicated so I'd rather avoid this.) Should I literally just use a stringbuilder to construct a javascript function containing the proper json array and then append that function to the page? That would work, but it doesn't seem quite proper.