您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“web開發(fā)中怎么在網(wǎng)站上添加谷歌定位信息”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習一下“web開發(fā)中怎么在網(wǎng)站上添加谷歌定位信息”這篇文章吧。
首先包括jQuery庫
<script type="text/javascript" src="jquery.js"></script> jQuery(function() { //call navigator object to get latitude and logtitute if(navigator.geolocation) { //getting current latitude and longtitude navigator.geolocation.getCurrentPosition(function(position) { //get location details based on latitude and longtitude from Google var jsonUrl = "https://maps.googleapis.com/maps/api/geocode/json?latlng="+position.coords.latitude+","+position.coords.longitude jQuery.getJSON(jsonUrl , function( data ) { var results = data.results[0]; console.info(results); //check firebug alert(results.address_components[5].long_name); //City alert(results.address_components[6].long_name); //State alert(results.address_components[7].long_name); //Country }, function(){ alert('Failed to get Location Details...'); }); return false; }); }});
以上是“web開發(fā)中怎么在網(wǎng)站上添加谷歌定位信息”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。