0byt3m1n1
Path:
C:
/
wamp64
/
www
/
GeoSpatial
/
[
Home
]
File: index.php.php
// PHP script generating GeoJSON data (similar to the previous example) $geojson = '{ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [40.7128, -74.0060] }, "properties": { "name": "New York City" } } ] }'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Leaflet Map</title> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script> </head> <body> <div id="map" style="width: 600px; height: 400px;"></div> <script> var map = L.map('map').setView([40.7128, -74.0060], 12); // Initial map view (New York City) L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }).addTo(map); // Adding GeoJSON layer to the map var geojsonData = <?php echo $geojson; ?>; L.geoJSON(geojsonData).addTo(map); </script> </body> </html>