How to connect to openstreetmap via API? I really can not find the normal information. I need to connect and put geo points
<? function get_saved_locations(){ $con=mysqli_connect ("localhost", 'root', '','locations'); if (!$con) { die('Not connected : ' . mysqli_connect_error()); } $sqldata = mysqli_query($con,"select lng,lat from locations "); $rows = array(); while($r = mysqli_fetch_assoc($sqldata)) { $rows[] = $r; } $indexed = array_map('array_values', $rows); // $array = array_filter($indexed); echo json_encode($indexed); if (!$rows) { return null; } } ?> <script> var map = L.map( 'map', { center: [57.08231,25.24116], minZoom: 1.5, zoom: 7 }) L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>', subdomains: ['a', 'b', 'c'] }).addTo( map ) var myURL = jQuery( 'script[src$="leaf-demo.js"]' ).attr( 'src' ).replace( 'leaf-demo.js', '' ) var myIcon = L.icon({ iconUrl: myURL + 'images/pin24.png', iconRetinaUrl: myURL + 'images/pin48.png', iconSize: [29, 24], iconAnchor: [9, 21], popupAnchor: [0, -14] }) for ( var i=0; i < markers.length; ++i ){ L.marker( [markers[i].lat, markers[i].lng], {icon: myIcon} ) .addTo( map ); </script>
It all works, but this is output for JSON, and I need from the MYSQL database, there are only 2 lat lng columns
<? $con=mysqli_connect ("localhost", 'root', '','locations'); if (!$con) { die('Not connected : ' . mysqli_connect_error()); } // update location with location_status if admin location_status. $sqldata = mysqli_query($con,"select lng,lat from locations "); $rows = array(); while($r = mysqli_fetch_assoc($sqldata)) { $rows[] = $r; } ?> var tempArray = JSON.parse("[<?echo $r?>]");