我有一个mySql数据库,其中包含由lat和lng指定的起始位置和结束位置的路线,以及起始日期和时间。

然后,我有了一个网页(经典asp),用户可以在其中使用Google Maps api输入日期,时间和位置。

当用户输入位置时,我想遍历数据库以查看在给定时间内是否有路线经过用户位置,然后显示结果,以便他可以选择自己的首选路线。

我一直在寻找isLocationOnEdge,但是我无法弄清楚如何使用它以及如何获得价值,因此我可以在asp中使用它。

我已经找到了此代码,但是正如我所说的-不知道必须使用它,因此它适合我的问题:

function initialize() {
  var mapOptions = {
    zoom: 5,
    center: new google.maps.LatLng(24.886, -70.269),
    mapTypeId: google.maps.MapTypeId.TERRAIN
  };

  var map = new google.maps.Map(document.getElementById('map-canvas'),
  mapOptions);

  var cascadiaFault = new google.maps.Polyline({
    path: [
      new google.maps.LatLng(49.95, -128.1),
      new google.maps.LatLng(46.26, -126.3),
      new google.maps.LatLng(40.3, -125.4)
    ]
  });

  var myPosition = new google.maps.LatLng(43.0, -125.9, 10e-7);

  if (google.maps.geometry.poly.isLocationOnEdge(myPosition,     cascadiaFault)) {
    alert("Relocate!");
  }
}

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


有谁能够帮助我?还是给我一些提示,我可以遵循?

最佳答案

好吧,显然google.maps.geometry.poly.isLocationOnEdge(myPosition, cascadiaFault)将返回一个可以测试的布尔值,因此我怀疑您只是想在JavaScript代码中生成一个值数组,类似...

<%
    Dim sql, c, joinLL, rs, conn
    sql = "SELECT lat, long, FROM myGeoTable WHERE condition = true "
    conn = Application("CONN_STRING")

    'Pass the string using RecordSet.GetString...
    Set rs = Server.CreateObject("ADODB.RecordSet")
    rs.Open sql, conn
    joinLL = "[new google.maps.LatLng(" & _
      rs.GetString(2, , ", ", "), new google.maps.LatLng(", "") & _
      "]"
    rs.Close
    Set rs = Nothing
%>


...,也许是这样的东西来测试您的长/短列表...

    // joinLL is the variable from the VB Script...
    var pLongLat = <%= joinLL %>;
    var llPoint;

    foreach(llPoint in pLongLat) {
        if(google.maps.geometry.poly.isLocationOnEdge(llPoint, cascadiaFault)) {
            //Do your processing
        }
    }


查看ADO RecordSet方法GetStringGetRows可能是值得的。它们非常有用且非常快。

10-05 20:32
查看更多