I make a site where the visitor gets his position shown on the map and within the selected radius (for example, 10 km), the visitor can see some POIs (for example, restaurants, bars).
I have this code:
<!DOCTYPE html> <html> <head> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map_canvas { height: 100% } </style> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=[MY_KEY]&sensor=false"> </script> <script type="text/javascript"> function init() { if(navigator.geolocation) { navigator.geolocation.getCurrentPosition (processPosition, handleError); } else { alert("Geolocation not supported in this browser"); } } function processPosition(pos) { var latlng = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude); var myOptions = { center: latlng, zoom: 16, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); var marker = new google.maps.Marker({ position: latlng, map: map, title:"You are here! (at least within a "+pos.coords.accuracy+" meter radius)" }); } function handleError(err) { alert('An error occurred: ' + err.code); } </script> </head> <body onload="init()"> <div id="map_canvas" style="width:100%; height:100%"></div> </body> </html>
This shows me my position on a map with a marker using Google Maps.
The fact is that I would like to use maps from OpenStreetMap (they are updated regularly, but there are no restrictions), but, unfortunately, I have not yet been able to implement it.
Here are the cards I need: Maps
1. Is there an example (tutorial) that shows how to use their APIs, for example Google ?
2. Is there something like a POI in OpenStreetMap, such as Google Places ? Or is it even possible to use Google Places with OpenStreetMap maps?
source share