Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#与asp.net谷歌地图_C#_Asp.net_Google Maps - Fatal编程技术网

c#与asp.net谷歌地图

c#与asp.net谷歌地图,c#,asp.net,google-maps,C#,Asp.net,Google Maps,好吧,我已经连续做了好几个小时了。我无法获取包含数据的地图。我确实让它显示了地图,但现在不起作用。我正在使用linq并从数据库中提取数据。我希望我可以压缩我的文件并发送,但我会尽力解释。提前谢谢 以下是apxdesign页面的代码 <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"> </script> <scrip

好吧,我已经连续做了好几个小时了。我无法获取包含数据的地图。我确实让它显示了地图,但现在不起作用。我正在使用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>

如果在地址查找时进行调试,则正确地显示了“地址、城市、州、邮政编码”。目前,我硬编码了变量,这样我就可以看到是否有任何东西在工作。你至少能找出问题所在吗?如果JavaScript被破坏,我可以提供帮助,但我对C#、Linq或Asp一无所知。例如,我注意到zoom和center都被注释掉了,我相信它们都是显示mapI所必需的。我认为问题可能出在js代码的这一部分:var addresslookup=;使用var addresslookup=''更正它;好的,我把额外的函数去掉,把它作为一个整体来工作。我不明白为什么它会起作用。我也无意中取消了它的注释,然后我不得不把“”放在裙子上。如果我在设计页面上重新输入函数codeaddress,它就会中断。我不知道为什么设计页面不喜欢做两个功能。
 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;   
    }