獲取數據時,以GeoJSON這樣我就可以從MySQL將這個PHP查詢LeafletJS不顯示地圖從MySQL
while($row = mysql_fetch_assoc($dbquery)) {
$feature = array(
'type' => 'Feature',
'geometry' => array(
'type' => 'Point',
'coordinates' => array((float)$row['lng'], (float)$row['lat'])
),
'properties' => array(
'pano' => $row['pano']
//Other fields here, end without a comma
)
);
array_push($geojson['features'], $feature);
得到的數據,並呼應與json_encode($ GeoJSON的,JSON_NUMERIC_CHECK)數組的時候;結果是
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[25.726231,66.498966]},"properties":{"pano":"81_1_0.html"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[25.723139,66.50158]},"properties":{"pano":"81_1_0.html"}}]};
但是,當我試圖讓那些進入LeafletJS地圖上什麼也不顯示
var points = <?php echo json_encode($geojson, JSON_NUMERIC_CHECK); ?> ;
var geoJsonLayer = L.geoJson(points, {
pointToLayer: function (feature, latlng) {
var marker = L.circleMarker(latlng, geojsonMarkerOptions);
marker.on('click', function (e) {
var feature = e.target.feature;
var content = '<iframe width="665" height="650" frameborder="0" src="/' + feature.properties.pano + '">';
document.getElementById("event").innerHTML = content;
if (selectedMarker != false) {
selectedMarker.setStyle({
fillColor: "#ff7800"
});
}
marker.setStyle({
fillColor: "#000000"
});
selectedMarker = marker;
});
return marker;
}
});
markers.addLayer(geoJsonLayer);
我做錯了的是什麼?
它是否在控制檯中給出任何錯誤? – Khushboo
@Khushboo沒有錯誤或任何控制檯 – somnium
geojsonMarkerOptions中有什麼? – Khushboo