Include openlayers in the site and add a function that shows a map on the page.
This commit is contained in:
parent
ff896015bb
commit
d34067297e
1 changed files with 18 additions and 0 deletions
18
map.php
Normal file
18
map.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<link rel="stylesheet" href="openlayers/ol.css" />
|
||||
<script src="openlayers/ol.js"></script>
|
||||
|
||||
<?php
|
||||
function ShowMap($lat,$lon){
|
||||
echo '<script>';
|
||||
echo 'var pos = new ol.proj.fromLonLat([' . $lon . ', ' . $lat . ']);';
|
||||
echo 'var map = new ol.Map({target:"map"});';
|
||||
echo 'var osmSource = new ol.source.OSM();';
|
||||
echo 'var myview = new ol.View({center: pos, zoom: 12});';
|
||||
echo 'map.setView(myview);';
|
||||
echo 'var osmLayer = new ol.layer.Tile({source: osmSource});';
|
||||
echo 'map.addLayer(osmLayer);';
|
||||
echo 'var marker = new ol.Overlay({position: pos, element: document.getElementById("marker")});';
|
||||
echo 'map.addOverlay(marker);';
|
||||
echo '</script>';
|
||||
}
|
||||
?>
|
Reference in a new issue