'Non interceptée InvalidValueError' (: setCenter: pas un LatLng ou LatLngLiteral objet)

Je commence à le connaître PHP et JavaScript, en les mélangeant en HTML et en utilisant l'API Google Maps (version 3).

J'ai compris comment mettre des marqueurs différents, mais la console me jeter une erreur:

" Uncaught InvalidValueError: setCenter: pas un LatLng ou LatLngLiteral objet ".

Je pense que c'est parce que le var a créé dans la boucle n'est pas exactement l'objet de besoin, mais au lieu d'une chaîne, bien que cela me confond, je ne sais pas si je suis à droite.

C'est mon code:
(En passant, le tableau que je suis en boucle est un tableau avec un tableau un tableau, voici quelques. Il suit le modèle, il y a au total 6 "lieux"):

$locations = array(
        array(
            'Location' => array(
                'Title'=>'Place',
                'Description'=>'Some Place',
                'Image'=>'pin1.png',
                'Latitude'=>'20.681775',
                'Longitude'=>'-103.351479'
            )
        ),…

(Continue...).

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { height: 100% }
    </style>    

        <script type="text/javascript"
          src="https://maps.googleapis.com/maps/api/js?AIzaSyBVfO8LckdOHAot1a8rZW0bmJIoWO2A3os=API_KEY&sensor=true">
        </script>


      <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: (20.68177501, -103.3514794),
          zoom: 15,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);

        //To add the marker to the map, use the 'map' property
        <?php $i = 0; ?>
        <?php foreach($locations as $key => $value): ?>
                <?php foreach($value as $key => $value): ?>
                    <?php foreach($value as $key => $value): ?>
                        <?php if($key == "Latitude"): ?>
                            <?php $myLatLng = "$value, "; endif;?>
                        <?php if($key == "Longitude"): ?>
                            <?php $myLatLng .="$value"; ?>

        var myLatlng<?php echo $i; ?> = new google.maps.LatLng(<?php echo $myLatLng; ?>);
        var marker<?php echo $i; ?> = new google.maps.Marker({
        position: (myLatlng<?php echo $i; ?>),
        title:"Hello World!"
        });
        marker<?php echo $i; ?>.setMap(map); 

                            <?php $i++; ?>
                        <?php endif; ?>
                    <?php endforeach; ?>
                <?php endforeach; ?>
        <?php endforeach; ?>
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>


  </head>
  <body>
    <div id="map-canvas"/>
  </body>
</html>

Et voici une capture d'écran de la var affectation d'une partie: https://dzwonsemrish7.cloudfront.net/items/3J403M213b3J1Y231j0g/Screen%20Shot%202013-11-15%20at%2001.03.57.png?v=c4809ed2

OriginalL'auteur James | 2013-11-15