使用google maps api将当前gps坐标发送到mySQL数据库
我正在尝试在jquery中构建一个高尔夫应用程序,我可以使用按钮将当前的gps坐标发送到mySQL数据库。
问题是我是php的新手,我正在尝试找到我可以使用的代码。 我建了一个数据库:
- ID int 3自动增量
- LAT浮动10
- LON浮10
有人可以帮助一些HTML和PHP代码吗?
Play 9 holes
Click the button to get your position:
var x=document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition,showError); } else{x.innerHTML="Geolocation is not supported by this browser.";} } function showPosition(position) { var latlon=position.coords.latitude+","+position.coords.longitude; var img_url="http://maps.googleapis.com/maps/api/staticmap?center=" +latlon+"&zoom=14&size=400x400&sensor=false"; document.getElementById("mapholder").innerHTML=""; } function showError(error) { switch(error.code) { case error.PERMISSION_DENIED: x.innerHTML="User denied the request for Geolocation." break; case error.POSITION_UNAVAILABLE: x.innerHTML="Location information is unavailable." break; case error.TIMEOUT: x.innerHTML="The request to get user location timed out." break; case error.UNKNOWN_ERROR: x.innerHTML="An unknown error occurred." break; } }
此代码显示当前位置,但必须有一个请求函数,可以发送position.coords.latitude +“,”+ position.coords.longitude到数据库?
我真的不确定你要做什么,但是Google Maps API网站上的一些文章使用PHP和MySQL以及Google Maps API:
https://developers.google.com/maps/articles/phpsqlsearch_v3
https://developers.google.com/maps/articles/phpsqlajax_v3