为什么会收到“ InvalidValueError:不是LatLng或LatLngLiteral”的信息?

时间:2019-01-05 02:19:07

标签: javascript php html5 google-maps

使用Google Map API对交付服务Web应用进行编码。直到我开始使用multi-dem数组作为LatLng参考之前,都没有问题。现在我收到了这个奇怪的错误-

“ InvalidValueError:不是LatLng或LatLngLiteral”

我之前为LatLng使用了类似的数组引用,没问题,但是现在它是多点数组,我遇到了这个奇怪的错误。

<?php
session_start();

require 'ConnectTest.php';

            // IF YOU'RE NOT LOGGED IN, KICK BACK TO LOGIN SCREEN
            if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){

                header("Location:signin.php");
            }


            $servername = "localhost:3306";
            $user = "sonic_client";
            $pass = "client";
            $dbName = "sonicStrains";

            $drop = "DROP TABLE ".$_SESSION['username']."_deliveries";
            mysqli_query($server, $drop);

            //CREATE INDIVIDUAL DRIVER TABLE TO HOLD DELIVERIES
            $createQuery = "CREATE TABLE ".$_SESSION['username']."_deliveries (
                transaction_id VARCHAR(13),
                timePaid INT(11),
                username VARCHAR(30),
                user_location VARCHAR(255),
                user_lat float(10,6),
                user_long float(10,6),
                item_name VARCHAR(20),
                item_quantity float,
                driver_username VARCHAR(60),
                driver_lat float(10,6),
                driver_long float(10,6),
                on_delivery tinyint(1))";

            $created = mysqli_query($server, $createQuery);

            if ($created){

                //query the deliveries for open deliveries up untill 5 deliveries
                $queryString = "SELECT * FROM deliveries LIMIT 5";

                $query = mysqli_query($server, $queryString);

                if($query){


                    // CREATE ARRAY TO HOLD QUERY ROWS
                    $rows = array();

                    while($queryresult = mysqli_fetch_assoc($query)){

                        $rows[] = $queryresult;


                    }



                    echo floatval($rows[0]['user_lat']);
                    echo"<br>";

                    //INSERT & UPDATE THE TABLES WITH DELIVERY QUERIES
                    foreach($rows as $row){



                        // INSERT INTO INDIVIDUAL DRIVER TABLE
                        $insertQuery = "INSERT INTO ".$_SESSION['username']."_deliveries (transaction_id, user_location, user_lat, user_long) VALUES('$row[transaction_id]', '$row[user_location]', '$row[user_lat]', '$row[user_long]')";
                        $insertExec = mysqli_query($server, $insertQuery);



                        // UPDATE MASTER LIST OF DELIVERIES SO THAT OTHER DRIVERS DONT QUERY SAME ORDER
                        $updateQuery = "UPDATE deliveries SET on_delivery=true, driver_username='$_SESSION[username]' WHERE transaction_id='$row[transaction_id]'";
                        $updateExec = mysqli_query($server, $updateQuery);



                    }

                }else{echo mysqli_error($server);}




            }else{echo mysqli_error($server);}


            if(isset($_GET['pop'])){


                array_shift($rows);
                echo print_r($rows);
            }

            echo<<<_

                        <!DOCTYPE html>
                        <html>

                        <head>

                        <meta name="viewport" content="width=device-width, initial-scale=1">
                        <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">


                        </head> 



                        <body>

                        <div class="Banner">
                            <div class="TitleText">Sonic Strains &copy;</div>
                        </div>


                        <div class="login">Logout</div>
                        <div class="gallery" id="container">
                            <div class="map" id="mapInsert"></div>
                            <div class="navButton">Start Nav</div><div class="orderButton">Order Details</div>
                            <div class="abortButton">Abort</div><div class="confirmButton" onclick="shiftOrder()">Confirm</div><div class="disclaimer"></div>
                        </div>


                        <script>




                              function initMap() {

                                navigator.geolocation.getCurrentPosition(function(position) {




                                    var initialLocation = {lat:$rows[0]['user_lat'], lng:$rows[0]['user_long']};
                                    var Map = new google.maps.Map(document.getElementById('mapInsert'));
                                    Map.setCenter(initialLocation);
                                    Map.setZoom(13);
                                    // MAKE ANOTHER MARKER FOR THE CLIENT LOCATION
                                            var userLocation = {lat:$rows[0]['user_lat'], lng:$rows[0]['user_long']};
                                            var marker = new google.maps.Marker({
                                                position:userLocation, 
                                                map:Map,
                                                draggable:false, 
                                                clickable:false
                                                });
                                            marker.setMap(Map);



                                }, function(positionError) {

                                    alert('Location could not be found');
                                  },{enableHighAccuracy:true, timeout: 3000, maximumAge:1000});

                              } 

                              function shiftOrder(){

                                  var http = new XMLHttpRequest();
                                  http.onreadystatechange = function(){
                                      console.log(this.responseText);

                                  }
                                  http.open("GET", "driverIndex.php?pop='pop'", true);
                                  http.send();

                              }


                        </script>
                        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=[API_KEY]&callback=initMap" 
                            async defer></script>




                        </body>
                        </html>

_;

?>  

这里是ref数组的一个元素的一瞥-

  array(5) { [0]=> array(12) { ["transaction_id"]=> string(13) "5c2fb27078926" ["timePaid"]=> string(1) "0" ["username"]=> string(0) "" ["user_location"]=> string(44) "1301 Bataan St NW, Washington, DC 20036, USA" ["user_lat"]=> string(9) "38.907246" ["user_long"]=> string(10) "-77.037292" ["item_name"]=> string(18) "girl_scout_cookies" ["item_quantity"]=> string(1) "1" ["driver_username"]=> string(7) "Driver1" ["driver_lat"]=> string(8) "0.000000" ["driver_long"]=> string(8) "0.000000" ["on_delivery"]=> string(1) "1" } 

再次,我尝试使用floatval()解析经纬度,因为它说的不是数字

  var initialLocation = {lat:floatval($rows[0]['user_lat']), lng:floatval($rows[0]['user_long'])};

但是我得到了“未定义floatval”

1 个答案:

答案 0 :(得分:0)

PHP变量不在方括号内-

docker.build("my-image:${env.BUILD_ID}", "--build-arg HTTP_PROXY=http://192.168.0.1:3128", "-f ${dockerfile} ./dockerfiles")