• <bdo id='CRbL9'></bdo><ul id='CRbL9'></ul>

        <tfoot id='CRbL9'></tfoot>
      1. <small id='CRbL9'></small><noframes id='CRbL9'>

      2. <legend id='CRbL9'><style id='CRbL9'><dir id='CRbL9'><q id='CRbL9'></q></dir></style></legend>
        <i id='CRbL9'><tr id='CRbL9'><dt id='CRbL9'><q id='CRbL9'><span id='CRbL9'><b id='CRbL9'><form id='CRbL9'><ins id='CRbL9'></ins><ul id='CRbL9'></ul><sub id='CRbL9'></sub></form><legend id='CRbL9'></legend><bdo id='CRbL9'><pre id='CRbL9'><center id='CRbL9'></center></pre></bdo></b><th id='CRbL9'></th></span></q></dt></tr></i><div id='CRbL9'><tfoot id='CRbL9'></tfoot><dl id='CRbL9'><fieldset id='CRbL9'></fieldset></dl></div>

        只有 HTML/JS 和谷歌地图上的实时 GPS 追踪器可以在手机上运行?是否可以?

        Real time GPS Tracker on JUST HTML / JS and Google Maps to be run on a handphone? Is it possible?(只有 HTML/JS 和谷歌地图上的实时 GPS 追踪器可以在手机上运行?是否可以?)

          <bdo id='gyWbp'></bdo><ul id='gyWbp'></ul>
          <legend id='gyWbp'><style id='gyWbp'><dir id='gyWbp'><q id='gyWbp'></q></dir></style></legend>
              <tbody id='gyWbp'></tbody>
            • <small id='gyWbp'></small><noframes id='gyWbp'>

                <tfoot id='gyWbp'></tfoot>
              1. <i id='gyWbp'><tr id='gyWbp'><dt id='gyWbp'><q id='gyWbp'><span id='gyWbp'><b id='gyWbp'><form id='gyWbp'><ins id='gyWbp'></ins><ul id='gyWbp'></ul><sub id='gyWbp'></sub></form><legend id='gyWbp'></legend><bdo id='gyWbp'><pre id='gyWbp'><center id='gyWbp'></center></pre></bdo></b><th id='gyWbp'></th></span></q></dt></tr></i><div id='gyWbp'><tfoot id='gyWbp'></tfoot><dl id='gyWbp'><fieldset id='gyWbp'></fieldset></dl></div>

                  本文介绍了只有 HTML/JS 和谷歌地图上的实时 GPS 追踪器可以在手机上运行?是否可以?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我阅读了 GPS 实时跟踪并发现了一些关于它的内容,主要是需要 PHP、zope 和一个数据库来存储传入的数据.其他一些方法使用与 PHP 相关的 ajax.

                  I have read up on GPS Real time tracking and found out several things about it, mostly requiring PHP, zope and a database to store the incoming data. Some other methods uses ajax with relations to PHP.

                  关于我的问题,当您在城市的任何地方移动时,是否可以仅使用 html 和 JS、使用标记或其他任何东西来填充 Google 地图?在这方面需要一些帮助,谢谢!

                  As regards to my question, is it possible to do so with just html and JS, using markers or anything else to populate the Google Map when you move anywhere in the city? Need some help on this, Thanks!

                  推荐答案

                  是的,有可能.最新智能手机中的大多数浏览器都实现了 W3C Geolocation API:

                  Yes, it is possible. Most browsers in the latest smartphones have implemented the W3C Geolocation API:

                  Geolocation API 为位置信息定义了一个高级接口,该接口仅与托管实施的设备相关联,例如纬度和经度.API 本身与底层位置信息源无关.位置信息的常见来源包括全球定位系统 (GPS) 和从网络信号(如 IP 地址、RFID、WiFi 和蓝牙 MAC 地址、GSM/CDMA 小区 ID)以及用户输入推断的位置.不保证 API 会返回设备的实际位置.

                  The Geolocation API defines a high-level interface to location information associated only with the device hosting the implementation, such as latitude and longitude. The API itself is agnostic of the underlying location information sources. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. No guarantee is given that the API returns the device's actual location.

                  API 旨在实现一次性"位置请求和重复位置更新,以及显式查询缓存位置的能力.

                  The API is designed to enable both "one-shot" position requests and repeated position updates, as well as the ability to explicitly query the cached positions.

                  使用 Geolocation API 在 Google 地图上绘制一个点,将如下所示:

                  Using the Geolocation API to plot a point on Google Maps, will look something like this:

                  if (navigator.geolocation) { 
                    navigator.geolocation.getCurrentPosition(function(position) {  
                  
                      var point = new google.maps.LatLng(position.coords.latitude, 
                                                         position.coords.longitude);
                  
                      // Initialize the Google Maps API v3
                      var map = new google.maps.Map(document.getElementById('map'), {
                         zoom: 15,
                        center: point,
                        mapTypeId: google.maps.MapTypeId.ROADMAP
                      });
                  
                      // Place a marker
                      new google.maps.Marker({
                        position: point,
                        map: map
                      });
                    }); 
                  } 
                  else {
                    alert('W3C Geolocation API is not available');
                  } 
                  

                  以上只会收集一次位置,当你开始移动时不会自动更新.要处理这个问题,您需要保留对标记的引用,定期调用 getCurrentPosition() 方法,并将标记移动到新坐标.代码可能如下所示:

                  The above will only gather the position once, and will not auto update when you start moving. To handle that, you would need to keep a reference to your marker, periodically call the getCurrentPosition() method, and move the marker to the new coordinates. The code might look something like this:

                  // Initialize the Google Maps API v3
                  var map = new google.maps.Map(document.getElementById('map'), {
                    zoom: 15,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                  });
                  
                  var marker = null;
                  
                  function autoUpdate() {
                    navigator.geolocation.getCurrentPosition(function(position) {  
                      var newPoint = new google.maps.LatLng(position.coords.latitude, 
                                                            position.coords.longitude);
                  
                      if (marker) {
                        // Marker already created - Move it
                        marker.setPosition(newPoint);
                      }
                      else {
                        // Marker does not exist - Create it
                        marker = new google.maps.Marker({
                          position: newPoint,
                          map: map
                        });
                      }
                  
                      // Center the map on the new position
                      map.setCenter(newPoint);
                    }); 
                  
                    // Call the autoUpdate() function every 5 seconds
                    setTimeout(autoUpdate, 5000);
                  }
                  
                  autoUpdate();
                  

                  现在,如果通过跟踪您的意思是您还应该将此信息存储在服务器上(以便其他人可以看到您从远程位置移动),那么您必须使用将这些点发送到服务器端脚本AJAX.

                  Now if by tracking you mean that you should also store this information on a server (so that someone else could see you moving from a remote location), then you'd have to send the points to a server-side script using AJAX.

                  此外,请确保 Google Maps API 使用条款允许这种用法,在你从事这样的项目之前.

                  In addition, make sure that the Google Maps API Terms of Use allow this usage, before you engage in such a project.

                  更新: W3C 地理定位 API 公开了一个 watchPosition() 方法可以用来代替我们在上面示例中使用的 setTimeout() 机制.

                  UPDATE: The W3C Geolocation API exposes a watchPosition() method that can be used instead of the setTimeout() mechanism we used in the above example.

                  这篇关于只有 HTML/JS 和谷歌地图上的实时 GPS 追踪器可以在手机上运行?是否可以?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  <i id='cYivD'><tr id='cYivD'><dt id='cYivD'><q id='cYivD'><span id='cYivD'><b id='cYivD'><form id='cYivD'><ins id='cYivD'></ins><ul id='cYivD'></ul><sub id='cYivD'></sub></form><legend id='cYivD'></legend><bdo id='cYivD'><pre id='cYivD'><center id='cYivD'></center></pre></bdo></b><th id='cYivD'></th></span></q></dt></tr></i><div id='cYivD'><tfoot id='cYivD'></tfoot><dl id='cYivD'><fieldset id='cYivD'></fieldset></dl></div>
                    <bdo id='cYivD'></bdo><ul id='cYivD'></ul>

                      <tbody id='cYivD'></tbody>

                    <small id='cYivD'></small><noframes id='cYivD'>

                      • <tfoot id='cYivD'></tfoot><legend id='cYivD'><style id='cYivD'><dir id='cYivD'><q id='cYivD'></q></dir></style></legend>