Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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
Javascript 音隙地理定位标记_Javascript_Android_Cordova_Geolocation_Google Maps Markers - Fatal编程技术网

Javascript 音隙地理定位标记

Javascript 音隙地理定位标记,javascript,android,cordova,geolocation,google-maps-markers,Javascript,Android,Cordova,Geolocation,Google Maps Markers,我正在Phonegap Android上做一个关于GPS的项目。我想显示一些位置(医院、美食广场等),使用我当前的位置和位置的帮助 标记..在我下面的代码中,我成功获得了当前位置..但不知道 要显示其他位置的位置,请帮助我这是我的代码,谢谢 <script> function writeAddressName(latLng) { var geocoder = new google.maps.Geocoder(); geocoder.geocode({

我正在Phonegap Android上做一个关于GPS的项目。我想显示一些位置(医院、美食广场等),使用我当前的位置和位置的帮助 标记..在我下面的代码中,我成功获得了当前位置..但不知道 要显示其他位置的位置,请帮助我这是我的代码,谢谢

<script>
  function writeAddressName(latLng) {
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({
      "location": latLng
    },
    function(results, status) {
      if (status == google.maps.GeocoderStatus.OK)
        document.getElementById("address").innerHTML = results[0].formatted_address;
      else
        document.getElementById("error").innerHTML += "Unable to retrieve your address" + "<br />";
    });
  }

  function geolocationSuccess(position) {
    var userLatLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
    // Write the formatted address
    writeAddressName(userLatLng);

    var myOptions = {
      zoom : 16,
      center : userLatLng,
      mapTypeId : google.maps.MapTypeId.ROADMAP
    };
    // Draw the map
    var mapObject = new google.maps.Map(document.getElementById("map"), myOptions);
    // Place the marker
    new google.maps.Marker({
      map: mapObject,
      position: userLatLng
    });
    // Draw a circle around the user position to have an idea of the current localization accuracy
    var circle = new google.maps.Circle({
      center: userLatLng,
      radius: position.coords.accuracy,
      map: mapObject,
      fillColor: '#0000FF',
      fillOpacity: 0.5,
      strokeColor: '#0000FF',
      strokeOpacity: 1.0
    });
    mapObject.fitBounds(circle.getBounds());
  }

  function geolocationError(positionError) {
    document.getElementById("error").innerHTML += "Error: " + positionError.message + "<br />";
  }

  function geolocateUser() {
    // If the browser supports the Geolocation API
    if (navigator.geolocation)
    {
      var positionOptions = {
        enableHighAccuracy: true,
        timeout: 10 * 1000 // 10 seconds
      };
      navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationError, positionOptions);
    }
    else
      document.getElementById("error").innerHTML += "Your browser doesn't support the Geolocation API";
  }

  window.onload = geolocateUser;
</script>
<style type="text/css">
  #map {
    width: 500px;
    height: 500px;
  }
</style>
</head>
<body>
   <h1>Basic example</h1>
<div id="map"></div>
<p><b>Address</b>: <span id="address"></span></p>
<p id="error"></p>
</body>
</html>

函数writedDressName(latLng){
var geocoder=new google.maps.geocoder();
地理编码({
“位置”:latLng
},
功能(结果、状态){
if(status==google.maps.GeocoderStatus.OK)
document.getElementById(“地址”).innerHTML=results[0]。格式化的\u地址;
其他的
document.getElementById(“错误”).innerHTML+=“无法检索您的地址”+”
”; }); } 功能地理定位成功(职位){ var userLatLng=new google.maps.LatLng(position.coords.latitude,position.coords.longitude); //写格式化的地址 writeAddressName(userLatLng); 变量myOptions={ 缩放:16, 中心:userLatLng, mapTypeId:google.maps.mapTypeId.ROADMAP }; //画地图 var mapObject=new google.maps.Map(document.getElementById(“Map”),myOptions); //放置标记 新的google.maps.Marker({ map:mapObject, 职位:userLatLng }); //围绕用户位置画一个圆圈,了解当前定位精度 var circle=new google.maps.circle({ 中心:userLatLng, 半径:位置、坐标、精度, map:mapObject, 填充颜色:“#0000FF”, 填充不透明度:0.5, strokeColor:“#0000FF”, 笔划不透明度:1.0 }); fitBounds(circle.getBounds()); } 函数地理位置错误(位置错误){ document.getElementById(“error”).innerHTML+=“error:”+positionError.message+“
”; } 函数geolocateUser(){ //如果浏览器支持地理定位API if(导航器.地理位置) { 变量位置选项={ EnableHighAccurance:正确, 超时:10*1000//10秒 }; navigator.geolocation.getCurrentPosition(geolocationSuccess、geolocationError、positionOptions); } 其他的 document.getElementById(“错误”).innerHTML+=“您的浏览器不支持地理位置API”; } window.onload=地理位置用户; #地图{ 宽度:500px; 高度:500px; } 基本示例 地址:


您是否有医院、食品和食品的lat和lng位置Court@AmitPrajapati:是的,我有…实际上我可以通过数组显示它,但这里我的问题是我想要当前位置以及我周围的医院…可能吗