我有一个关于使用 php 脚本从 sqlite 导出数据并将其解析为谷歌地图的问题。
我已经在 php 上编写了一个查询脚本,但我不确定如何将它解析到我的谷歌地图中。我确实尝试过四处搜索,但我不是一个非常技术性的人,因此我在实施它时遇到了问题。
这是我的 php 查询的结果
array(18) {
[0]=>
array(3) {
["mac"]=>
string(17) "00:60:64:af:b9:be"
["lat"]=>
float(-27.5759707)
["lon"]=>
float(153.0646822)
}
[1]=>
array(3) {
["mac"]=>
string(17) "00:60:64:af:b9:be"
["lat"]=>
float(114.29077148438)
["lon"]=>
float(30.566990873153)
}
[2]=>
array(3) {
["mac"]=>
string(17) "10:60:64:af:b9:be"
["lat"]=>
float(-110.390625)
["lon"]=>
float(59.175928249271)
}
这是我当前的谷歌地图脚本,它正在解析来自 json 文件的数据。
<script type="text/javascript">
var infowindow = new google.maps.InfoWindow({});
//createMarker function
function createMarker(latLng, title, content,icon) {
var marker = new google.maps.Marker({
position: latLng,
map: map,
title: title,
});
//Onclick listener(mouseover)
google.maps.event.addListener(marker, "click", function() {
infowindow.setContent(content);
infowindow.open(map, marker);
});
}
// initialization function (focus location ,map type and zoom level)
function initialize() {
var mapOptions = {
zoom: 5,
center: new google.maps.LatLng(-27.48939, 153.012772),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
//reading location file
var script = document.createElement('script');
script.src = '\week.json';
document.getElementsByTagName('head')[0].appendChild(script);
}
//eqfeed call back will take result array and loop through each marker
window.eqfeed_callback = function(results) {
var bounds=new google.maps.LatLngBounds();
for (var i = 0; i < results.features.length; i++) {
var wifin = results.features[i];
var coords = wifin.geometry.coordinates;
var latLng = new google.maps.LatLng(coords[0],coords[1]);
bounds.extend(latLng);
var content ="<div style='height:100px; width:300px; overflow:auto;'><table>";
content += "<tr><th align='left'>WifiMacAddress</th><td>"+wifin.properties.WifiMacAddress+"</td></tr>";
content += "<tr><th align='left'>SSID</th><td>"+wifin.properties.SSID+"</td></tr>";
content += "<tr><th align='left'>SignalStrength</th><td>"+wifin.properties.SignalStrength+"</td></tr>";
content += "<tr><th align='left'>WifiFrequency</th><td>"+wifin.properties.WifiFrequency+"</td></tr>";
content +="</table>";
createMarker(latLng,wifin.WifiMacAddress,content);
}
map.fitBounds(bounds);
}
</script>