1

好的,我已经为此工作了几个小时。我无法获取地图以提取数据。我确实让它显示了地图,但现在不起作用。我正在使用 linq 并从数据库中提取。我希望我可以压缩我的文件并发送,但我会尝试解释。提前致谢。

这是apxdesign页面的代码

    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">      </script>
        <script type="text/javascript">

            var geocoder;
            var map;

            function ginit() {

                var geocoder;
                var map;
                function initialize() {

                    //var mapdouble = <%=MapID()%>;
                    var matt = -34.397;
                    var latlng = new google.maps.LatLng(matt, 150.644);
                    var myOptions = {
                        //zoom: 8, 
                        //center: latlng,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                    };
                    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
                }


                function codeAddress() {
                    var addresslookup = <%=gAddress()%>;
                    //var address = "9531 poplar hill drive crestwood kentucky 40014";
                    geocoder.geocode({ address: address }, function (results, status) {

                        if (status == google.maps.GeocoderStatus.OK) {

                            map.setCenter(results[0].geometry.location);

                            var marker = new google.maps.Marker({

                                map: map,
                                position: results[0].geometry.location

                            });
                        } else {

                            alert("Geocode was not successful for the following reason: " + status);

                        }
                    });
                }
            }
          </script>
    </head>
    <body onload="ginit()">
        <form id="form1" runat="server">
        <div id="map_canvas" style="height: 400px; width: 400px">
        </div>
        </form>
    </body>
    </html>

这是页面背后的代码。在我尝试地理编码之前它一直有效。只需映射它,但只要我添加其他代码,它就会中断。我确实有正确的变量过来,我也尝试手动添加它们。

这是编码页面

 namespace WebApplication7
 {
public partial class WebForm1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        //string id = Request.QueryString["ID"];
       // MapID();
        //gAddress();
    }

    public double MapID()
    {
        //string id = Page.Request.QueryString["ID"];
        double id = -34.397;

        double mapdouble = Convert.ToDouble(id);

        //Page.Response.Write(" here is the id " + id);

        return mapdouble;
    }


    public  string gAddress()
    {

        string newid = Page.Request.QueryString["ID"];

        double gid = Convert.ToDouble(newid);

        DataClasses1DataContext db = new DataClasses1DataContext();
        var address =(from p1 in db.Customers
                      where p1.ID == gid                          
                      select  p1.Address ).FirstOrDefault();

        var city = (from p1 in db.Customers
                       where p1.ID == gid
                       select p1.City).FirstOrDefault();

        var state = (from p1 in db.Customers
                    where p1.ID == gid
                    select p1.State).FirstOrDefault();


        var zip = (from p1 in db.Customers
                       where p1.ID == gid
                       select p1.Zip).FirstOrDefault(); 

        string addresslookup = address +", " + city +", " + state +", "+ zip;

         //Response.Write(address);
        return addresslookup;   
    }
4

0 回答 0