如何在asp.net中获取地图上的数据库地址

how can i get the database address on the map in asp.net

本文关键字:地图 数据库 地址 获取 asp net      更新时间:2023-09-26

对于相应的id,我希望标记指向该id的数据库地址。我该怎么做?我在哪里可以得到代码?我使用的是JS、Asp.Net、Sql服务器

这很简单,你必须创建一个数据库表,其中包括你地址的纬度和经度。。如果你需要一个简单的英文地址,那么你必须使用谷歌地理定位API,在存储地址后,然后对位置表中的每个条目执行以下操作In.cs

 public StringBuilder locs = new StringBuilder(); //globalVariable
     StringBuilder sb = new StringBuilder();
         foreach (Location l in loc)
                            {
                                longitude = l.Yaxis; //where Yaxis is a variable in class Location to store  longitude
                                lattudei = l.Xaxis; //where Xaxis is a variable in class Location to store  Latitutde
                                sb.Append(string.Format(
                                "['{2}','{0}','{1}','../Img/Icons/Vehicles/icon_{2}.png'],",
                                lati, lon, imgurl);
                            }
    locs.Append(sb.ToString());

.aspx

 <script>
  var map;
 map = new google.maps.Map(document.getElementById('map'), {
                    zoom: 5,
                    minZoom: 4,
                    maxZoom: 8,
                    center: new google.maps.LatLng(30.03105543, -39.44091797),
                });
    var locations = [<%=locs %> ];
     var markers=[];
     for (i = 0; i < locations.length; i++) {
                    var marker = new google.maps.Marker({
                        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
                        map: map,
                        icon: new google.maps.MarkerImage(locations[i][3] + "?" + new Date().getTime(), 
                            null, null, null, new google.maps.Size(40,15)),
                        id: locations[i][0],

                       });
                    markers.push(marker);
    </script>