salut ,
j'ai un problème avec mon programme je veux affixher une carte dans ma page web avec des markers et des infowindows. ces derniers cotiennent un lien vers une autre page. J'ai pas réussi à afficher ce lien
voila mon code .
le fichier .aspx.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
 
 
 
 
 
namespace OpenAndReadExcel
{
    public partial class _Default : System.Web.UI.Page
    {
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Excel.Application appExl;
                Excel.Workbook workbook;
                Excel.Worksheet NwSheet;
                Excel.Range ShtRange;
                appExl = new Excel.ApplicationClass();
                workbook = appExl.Workbooks.Open(Server.MapPath("Global EPT P1&P2 11082011.xlsx"), Missing.Value, Missing.Value,
                    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                    Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
                NwSheet = (Excel.Worksheet)workbook.Sheets.get_Item(1);
 
                int Cnum = 0;
                int Rnum = 0;
 
                String Locations = "";
                ShtRange = NwSheet.UsedRange;
                DataTable dt = new DataTable();
                dt.Columns.Add("Site Name");
                dt.Columns.Add("Longitude");
                dt.Columns.Add("Latitude");
                for (Rnum = 2; Rnum <= ShtRange.Rows.Count; Rnum++)
                {
                    DataRow dr = dt.NewRow();
                    int f = 1;
                    for (Cnum = 1; Cnum <= 11; Cnum++)
                    {
 
                        if ((ShtRange.Cells[1, Cnum] as Excel.Range).Value2.ToString() == "Site Name" || (ShtRange.Cells[1, Cnum] as Excel.Range).Value2.ToString() == "Latitude" || (ShtRange.Cells[1, Cnum] as Excel.Range).Value2.ToString() == "Longitude")
                        {
                            dr[f - 1] = (ShtRange.Cells[Rnum, Cnum] as Excel.Range).Value2.ToString();
                            f++;
                        }
 
 
 
                    }
                    dt.Rows.Add(dr);
                    dt.AcceptChanges();
                }
 
 
                Session["data"] = dt;
 
                foreach (DataRow r in dt.Rows)
                {
                    // bypass empty rows	 	
                    //  if (r["Latitude"].ToString().Trim().Length == 0)
                    //    continue;
 
                    var Latitude = r["Latitude"].ToString();
                    var Longitude = r["Longitude"].ToString();
                    var Site = r["Site Name"].ToString();
                    //HtmlLink canonical = new HtmlLink();
                  //  canonical.Href = "http://example.com/Content/Default.aspx";
                   // canonical.Href = "http://Default.aspx";
                    var myHtml = "<b>" + Site + "</b><br /><a href='Default.aspx' style='color:#00303f;font:bold 12px verdana;' title='click to contact'>More details</a></div>";
                    // System.Diagnostics.Debug.Write(myHtml);
 
                    // create a line of JavaScript for marker on map for this record	
                    Locations += Environment.NewLine + " latlng = new GLatLng(" + Latitude + " , " + Longitude + ")" + Environment.NewLine + "map.addOverlay(createMarker1(latlng," +myHtml + "));";
                        //+ Environment.NewLine + "var greenIcon = new GIcon(G_DEFAULT_ICON);" + Environment.NewLine + "greenIcon.image = 'http://www.google.com/intl/en_us/mapfiles/ms/micons/green-dot.png';"
        // + Environment.NewLine + "   markerOptions = { icon: greenIcon };"
          // + Environment.NewLine + "   var marker = new GMarker(latlng, markerOptions);"
 
 
 
                  //  "GEvent.addListener(marker, 'click', function() { map.openInfoWindowHtml(latlng , " + myHtml + ");});"
 
 
         //  + Environment.NewLine + "marker.bindInfoWindowHtml("+myHtml+");"
           //  + Environment.NewLine + "map.addOverlay(marker);";
 
 
 
 
 
 
 
                }
                workbook.Close(true, Missing.Value, Missing.Value);
                appExl.Quit();
 
 
                //   Session["data"] = dt;
                js.Text = @"
 
<script type='text/javascript'>
    function initialize() {
        if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById('map_canvas'));
            map.setCenter(new GLatLng(45.05, 7.6667), 2);
 
 function createMarker1(latlng, myHtml) {
                var redIcon = new GIcon(G_DEFAULT_ICON);
                redIcon.image = 'http://mrant.net/wp3/wp-content/uploads/2011/05/Google_Maps_Marker.png';
                markerOptions = { icon: redIcon };
                var marker = new GMarker(latlng, markerOptions);
                GEvent.addListener(marker, 'click', function () {
                
                   map.openInfoWindowHtml(latlng, myHtml );
 
                });
                return marker;
            }
 
 
            var bounds = map.getBounds();
            var southWest = bounds.getSouthWest();
            var northEast = bounds.getNorthEast();
            var lngSpan = northEast.lng() - southWest.lng();
            var latSpan = northEast.lat() - southWest.lat();
            var latlng;     
 
 
 
 
                                " + Locations + @"  
 
 
 
 
 
 
 
 
 
            map.setUIToDefault();
            map.setMapType(G_HYBRID_MAP);
 
 
 
        }
    }  
 
 
 
 
</script> ";
            }
        }
 
    }
}
voila le fichier .aspx

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="OpenAndReadExcel._Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
 
 
 
 
 
<title>Huawei Map</title>
 
<head>
    <style type="text/css">
 
        .style2
        {
            font-size: 60pt;
        }
        .style6
        {
            color: #006600;
        }
        .style1
        {
            text-align: center;
        }
        </style>
 
    <%--Google API reference--%>
 
 
</head>
 
<body onload="initialize()" onunload="GUnload()">
 
<form id="form1" runat="server">
 
 
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
 
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
 
type="text/javascript"></script> 
 
 
 
 
 
 <asp:Panel ID="Panel1" runat="server">
                <%--Place holder to fill with javascript by server side code--%>
                <asp:Literal ID="js" runat="server"></asp:Literal>
                <%--Place for google to show your MAP--%>
                <div ID="map_canvas" style="width: 100%; height: 728px; margin-bottom:                      2px;">
                </div>
                <br />
            </asp:Panel>
 
            <br />
 
           <span class="style2"><span class="style6" 
    style="color: #800000; font-style: italic; font-size: small">
<span class="style1" 
    style="font-size: xx-large; color: #009900; font-weight: 700">
<span class="style1">
<asp:Button ID="Button2" runat="server" BackColor="#CCCCCC" 
    BorderColor="#CCCCCC" BorderStyle="Double" ForeColor="Maroon" 
    PostbackUrl="~/Default.aspx" 
    style="font-size: x-large; font-weight: 700" Text="Previous" Width="143px" />
</span></span></span></span>
 
 
 
</form>
 
</body>
 
</html>



J'ai besoin d'aide SVP merciii