我的问题基本上是这样的: 如何从SQL Server转换数据并将其映射到Leaflet? 提示:如果这有任何帮助,我们正在运行Coldfusion 11,SQL Server 2000,Leaflet和JQuery。如果我需要下载一个javascript库,我可以轻松地这样做。
我在拥有xy坐标的数据库中有救护车和火灾事件。我的目标是查询当前事件并将它们放在Leaflet地图上。我们所有的救护车和消防车都装有GPS,他们不断播放他们的位置和状态。以下是我获取每辆卡车最新gps数据的查询;
SELECT
DateTimeStamp
, RTRIM(CallSign) AS [CallSign]
, RTRIM(UnitStatus) AS [UnitStatus]
, Latitude
, Longitude
, CONVERT(VARCHAR(15), DateTimeStamp, 106) AS [CurrentDate]
, CONVERT(VARCHAR(10), DateTimeStamp, 108) AS [CurrentTime]
FROM FireEMSGPSDatabase
RIGHT OUTER JOIN
(
SELECT
RTRIM(CallSign) AS [Ambulance]
, MAX(DateTimeStamp) AS [MostRecentTime]
FROM HISTORY_201506
WHERE RTRIM(CallSign) LIKE 'LCM__'
GROUP BY RTRIM(CallSign)
)
AS [MostRecent] ON DateTimeStamp = MostRecent.MostRecentTime
ORDER BY RTRIM(CallSign) ASC*
显示以下是此查询的示例输出;
DateTimeStamp CallSign UnitStatus Latitude Longitude CurrentDate CurrentTime
2015-06-04 17:14:17.357 LCM01 AQ 26.56428 -81.87044 04 Jun 2015 17:14:17
2015-06-04 17:14:17.357 LCM01 AQ 26.56428 -81.87044 04 Jun 2015 17:14:17
2015-06-04 17:14:18.670 LCM02 AQ 26.64074 -81.86507 04 Jun 2015 17:14:18
2015-06-04 17:14:34.420 LCM03 AR 26.64157 -81.90973 04 Jun 2015 17:14:34
2015-06-04 17:14:20.420 LCM04 TA 26.63885 -81.94159 04 Jun 2015 17:14:20
2015-06-04 17:14:21.297 LCM05 AQ 26.4377 -82.07806 04 Jun 2015 17:14:21
下面显示的是我的Coldfusion页面,其中添加了传单地图,cfquery带有cfoutput;
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css"/>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
</head>
<body>
<cfquery datasource="GPSDatabase" name="AmbulanceLocation">
SELECT
DateTimeStamp
, RTRIM(CallSign) AS [CallSign]
, RTRIM(UnitStatus) AS [UnitStatus]
, Latitude
, Longitude
, CONVERT(VARCHAR(15), DateTimeStamp, 106) AS [CurrentDate]
, CONVERT(VARCHAR(10), DateTimeStamp, 108) AS [CurrentTime]
FROM FireEMSGPSDatabase
RIGHT OUTER JOIN
(
SELECT
RTRIM(CallSign) AS [Ambulance]
, MAX(DateTimeStamp) AS [MostRecentTime]
FROM HISTORY_201506
WHERE RTRIM(CallSign) LIKE 'LCM__'
GROUP BY RTRIM(CallSign)
)
AS [MostRecent] ON DateTimeStamp = MostRecent.MostRecentTime
ORDER BY RTRIM(CallSign) ASC
</cfquery>
<cfoutput query="AmbulanceLocation">
<table>
<tr>
<td>#DateTimeStamp#</td>
<td>#CallSign#</td>
<td>#UnitStatus#</td>
<td>#Latitude#</td>
<td>#Longitude#</td>
<td>#CurrentDate#</td>
<td>#CurrentTime#</td>
</tr>
</table>
</cfoutput>
<div id="map"></div>
<script>
var map = L.map('map', {center: [26.5641867068354,-81.8704100173261],fullscreenControl: true, zoom: 12});
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);
</script>
</body>
</html>
总结一下;
我的问题是如何在Leaflet地图中绘制出坐标。 再来一次;我正在使用Coldfusion 11,SQL Server 2000,Leaflet和Jquery。数据库没有空间化 - 它只是原始整数和字符数据。 这个问题在Adobe Coldfusion论坛上交叉发布,但我在这里重新发布,因为有很多人经常访问这个网站。 我不是javascripting或Coldfusion专家。如果你能准确地说出你的想法,那将会帮助我很多。