Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在网站中创建位置意识_Php_Google Maps_Codeigniter_Geolocation_Google Maps Api 3 - Fatal编程技术网

Php 在网站中创建位置意识

Php 在网站中创建位置意识,php,google-maps,codeigniter,geolocation,google-maps-api-3,Php,Google Maps,Codeigniter,Geolocation,Google Maps Api 3,大家好,我已经用Google Maps V3 API和Codeigniter创建了一个web应用程序的核心部分,现在我想让网站知道用户的位置。根据我目前的知识,如果用户使用带有GPS传感器的手机/平板电脑,我将能够从用户的GPS传感器获取数据,或者从台式机/笔记本电脑浏览器的IP地址获取数据 我如何从他的手机上的GPS传感器获取他的位置(纬度/液化天然气?) 如何从他的浏览器的IP地址获取位置 我记得Firefox是一款位置感知浏览器。如果是firefox,如何访问位置数据?这是一个可行的选择吗

大家好,我已经用Google Maps V3 API和Codeigniter创建了一个web应用程序的核心部分,现在我想让网站知道用户的位置。根据我目前的知识,如果用户使用带有GPS传感器的手机/平板电脑,我将能够从用户的GPS传感器获取数据,或者从台式机/笔记本电脑浏览器的IP地址获取数据

  • 我如何从他的手机上的GPS传感器获取他的位置(纬度/液化天然气?)
  • 如何从他的浏览器的IP地址获取位置
  • 我记得Firefox是一款位置感知浏览器。如果是firefox,如何访问位置数据?这是一个可行的选择吗
  • 还有其他方法吗?(Wifi、手机塔三角测量?)

  • 在Google Maps API v3文档中阅读有关如何获取用户位置的所有信息:

    不管源是GPS传感器还是其他什么东西——你仍然可以用同样的方法得到它。在我看来,那里的文档或多或少地回答了你所有的四个问题

    以下是该页面中的相关示例代码:

    // Note that using Google Gears requires loading the Javascript
    // at http://code.google.com/apis/gears/gears_init.js
    
    var initialLocation;
    var siberia = new google.maps.LatLng(60, 105);
    var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
    var browserSupportFlag =  new Boolean();
    
    function initialize() {
      var myOptions = {
        zoom: 6,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
      // Try W3C Geolocation (Preferred)
      if(navigator.geolocation) {
        browserSupportFlag = true;
        navigator.geolocation.getCurrentPosition(function(position) {
          initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
          map.setCenter(initialLocation);
        }, function() {
          handleNoGeolocation(browserSupportFlag);
        });
      // Try Google Gears Geolocation
      } else if (google.gears) {
        browserSupportFlag = true;
        var geo = google.gears.factory.create('beta.geolocation');
        geo.getCurrentPosition(function(position) {
          initialLocation = new google.maps.LatLng(position.latitude,position.longitude);
          map.setCenter(initialLocation);
        }, function() {
          handleNoGeoLocation(browserSupportFlag);
        });
      // Browser doesn't support Geolocation
      } else {
        browserSupportFlag = false;
        handleNoGeolocation(browserSupportFlag);
      }
    
      function handleNoGeolocation(errorFlag) {
        if (errorFlag == true) {
          alert("Geolocation service failed.");
          initialLocation = newyork;
        } else {
          alert("Your browser doesn't support geolocation. We've placed you in Siberia.");
          initialLocation = siberia;
        }
        map.setCenter(initialLocation);
      }
    }
    

    在Google Maps API v3文档中阅读有关如何获取用户位置的所有信息:

    不管源是GPS传感器还是其他什么东西——你仍然可以用同样的方法得到它。在我看来,那里的文档或多或少地回答了你所有的四个问题

    以下是该页面中的相关示例代码:

    // Note that using Google Gears requires loading the Javascript
    // at http://code.google.com/apis/gears/gears_init.js
    
    var initialLocation;
    var siberia = new google.maps.LatLng(60, 105);
    var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
    var browserSupportFlag =  new Boolean();
    
    function initialize() {
      var myOptions = {
        zoom: 6,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };
      var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    
      // Try W3C Geolocation (Preferred)
      if(navigator.geolocation) {
        browserSupportFlag = true;
        navigator.geolocation.getCurrentPosition(function(position) {
          initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
          map.setCenter(initialLocation);
        }, function() {
          handleNoGeolocation(browserSupportFlag);
        });
      // Try Google Gears Geolocation
      } else if (google.gears) {
        browserSupportFlag = true;
        var geo = google.gears.factory.create('beta.geolocation');
        geo.getCurrentPosition(function(position) {
          initialLocation = new google.maps.LatLng(position.latitude,position.longitude);
          map.setCenter(initialLocation);
        }, function() {
          handleNoGeoLocation(browserSupportFlag);
        });
      // Browser doesn't support Geolocation
      } else {
        browserSupportFlag = false;
        handleNoGeolocation(browserSupportFlag);
      }
    
      function handleNoGeolocation(errorFlag) {
        if (errorFlag == true) {
          alert("Geolocation service failed.");
          initialLocation = newyork;
        } else {
          alert("Your browser doesn't support geolocation. We've placed you in Siberia.");
          initialLocation = siberia;
        }
        map.setCenter(initialLocation);
      }
    }
    

    您可能会发现这个问题是其中一些问题的良好起点:您可能会发现这个问题是其中一些问题的良好起点: