I'm having trouble finding how to approach this. The general idea is that my map is filled with markers with data coming from sql server database. The markers can display an infowindow containing a hyperlink to a single aspx page which dynamically loads the info of the clicked marker but I have yet to connect the two. It seems that I can't send or pass or reference the required data. Any help?

the markers are filled using a repeater

<asp:Repeater ID="rptMarkers" runat="server">
            "title": '<%# Eval("LandmarkName") %>',
            "lat": '<%# Eval("LandmarkLat") %>',
            "lng": '<%# Eval("LandmarkLong") %>',
            "description": '<%# Eval("LandmarkDesc") %>',
            "id": '<%# Eval("LandmarkID")%>'

Here's the javascript code

window.onload = function () {
                var mapOptions = {
                    center: new google.maps.LatLng(14.581, 120.976),
                    zoom: 12,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                var infoWindow = new google.maps.InfoWindow();
                var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
                for (i = 0; i < markers.length; i++) {
                    var data = markers[i]
                    var myLatlng = new google.maps.LatLng(data.lat, data.lng);
                    var marker = new google.maps.Marker({
                        position: myLatlng,
                        map: map,
                        title: data.title

                    (function (marker, data) {
                        var infotext = data.description + "<a href='#'>More Info</a>";
                        var id = data.id;
                        google.maps.event.addListener(marker, "click", function (e) {
                            infoWindow.open(map, marker);
                            document.getElementById("landmark").value = id;
                    })(marker, data);

            google.maps.event.addDomListener(window, 'load', initialize);
            window.onload = InitializeMap;

here's how the repeater is filled

DataTable dt = this.GetData(sql);
       rptMarkers.DataSource = dt;


    protected DataTable GetData(string query)
        SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
        SqlCommand cmd = new SqlCommand(query);
        using (SqlDataAdapter sda = new SqlDataAdapter())
            cmd.Connection = con;

            sda.SelectCommand = cmd;
            using (DataTable dt = new DataTable())
                return dt;

basically, the sql string calls an id which I want to use to load the data from the database in the other aspx page. what I've tried so far is setting a session state using the hidden input but I can't seem to make it work.

Thanks :D

Related posts

Recent Viewed