Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.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 在没有本地服务器的情况下运行cordova应用程序_Javascript_Jquery_Html_Json_Cordova - Fatal编程技术网

Javascript 在没有本地服务器的情况下运行cordova应用程序

Javascript 在没有本地服务器的情况下运行cordova应用程序,javascript,jquery,html,json,cordova,Javascript,Jquery,Html,Json,Cordova,我正在尝试使用此html页面运行cordova应用程序。该页面在本地服务器上运行良好,但在应用程序中无法运行。页面从json文件获取数据。Json文件包含用于在地图上定位标记的经度和纬度 <html> <head> <style type="text/css"> body { height: 100%; margin: 0; padding: 0 } #map_canvas { height: 100% } </style> <script

我正在尝试使用此html页面运行cordova应用程序。该页面在本地服务器上运行良好,但在应用程序中无法运行。页面从json文件获取数据。Json文件包含用于在地图上定位标记的经度和纬度

<html>
<head>
<style type="text/css">
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> 

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
    <link rel="stylesheet" type="text/css" href="css/index.css">
    <title>Hello World</title>

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" src = "http://maps.google.com/maps/api/js?key=AIzaSyBOliLL5Jrj-MH1-H-MspEVqJZn61uJP_0&sensor=false">
    </script>
    <script type="text/javascript">

    var Latit;
    var Longi;
    var i;
    $(function(){
            if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {

                document.addEventListener("deviceready", getPosition, false);
            } else {
                getPosition(); //this is the browser
            }
        })

       function getPosition() {

       var options = {
       enableHighAccuracy: true,
       maximumAge: 3600000
       }

       var watchID = navigator.geolocation.getCurrentPosition(onSuccess, onError, options);

       function onSuccess(position) {


 Latit = position.coords.latitude;
 Longi = position.coords.longitude;        
 };

  function onError(error) {
  alert('code: '    + error.code    + '\n' + 'message: ' + error.message + '\n');
  }
    }

   function initialize() {

    var point = new google.maps.LatLng(Latit,Longi);

     var map = new google.maps.Map(document.getElementById('map_canvas'), {
   zoom: 15,
  center: point,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});

  // Place a marker
  new google.maps.Marker({
  position: point,
  animation:google.maps.Animation.BOUNCE,
  map: map
  });



     $.getJSON('map_points.json', function(data) { //function requires local server
        $.each( data.points, function(i, value) {



            var myLatlng = new google.maps.LatLng(value.lat,value.lon);
            var marker = new google.maps.Marker({
            position: myLatlng,
            map: map,
            title: "position:"+value.lat+" , "+value.lon
            });

        google.maps.event.addListener(marker,'click',function() {
            var infoWindow = new google.maps.InfoWindow({
               content:'Address: '+value.Address
              });
         infoWindow.open(map,marker);
        });

        });
     });
    }

   </script>
  </head>
  <body onload="initialize()">
  <form id="form1" runat="server">
  <div id="map_canvas" style="width: 500px; height: 400px"></div>
  </form>
  <div> 
  </div>
    </body>
    </html>

您所说的本地服务器是什么意思?使用apache server.OK的localhost,它如何不在Cordova中运行?您需要提供有关问题的更多详细信息。使用cordova编译和生成时,应用程序中不会显示任何内容。
  {

  "points":[
 {"id":1,"lat":19.031166126834226,"lon":72.88102626800537,"Address":"imax"},{"id":2,"lat":19.073332920257027,"lon":72.89924383163452,"Address":"somaiya"},
 {"id":3,"lat":19.13302550300137,"lon": 72.91306257247925,"Address":"IIT Bombay"},
  {"id":4,"lat":19.123000520026086,"lon":72.9127112030983, "Address":"Gateway Plaza"}
   ]


  }