-2

重複の可能性:
JQuery の getJSON 関数で Google Places API を使用しようとしています

要素をテーブルに読み込もうとしています。

要素をテキストフィールドに取得しています。代わりに、表に表示したい..

以下はコードです

   function createMarker(place) {
        //var placeLoc = place.geometry.location;
        var request = {
          reference: place.reference
        };

        service = new google.maps.places.PlacesService(map);
        service.getDetails(request, callback);
        service.getDetails(request, function(details, status) {//alert("address  "+details.formatted_address);

        document.getElementById('box1').value=details.formatted_address;
        document.getElementById('box2').value=details.name;
        document.getElementById('box3').value=details.international_phone_number;

    });

  }
   google.maps.event.addDomListener(window, 'load', initialize);

  </script>
  </head>
  <body>

  <input type="text" id="box1" size="20"/>
  <input type="text" id="box2" size="50"/>
  <input type="text" id="box3" size="20"/>
    <div id="map"></div>
    <div id="text">

</body>
</html>
4

1 に答える 1

1
<html>
<head>
<style>
table {
  border-collapse: collapse;
}
table td, table th {
  border: 1px solid black;
}
table tr:first-child th {
  border-top: 0;
}
table tr:last-child td {
  border-bottom: 0;
}
table tr td:first-child,
table tr th:first-child {
  border-left: 0;
}
table tr td:last-child,
table tr th:last-child {
  border-right: 0;
}
</style>
<script>
  function createMarker(place) {
    //var placeLoc = place.geometry.location;
     var request = {
     reference: place.reference
    };

    service = new google.maps.places.PlacesService(map);
    service.getDetails(request, function(details, status) {//alert("address  "+details.formatted_address);

      document.getElementById('box1').innerHTML=details.formatted_address;
      document.getElementById('box2').innerHTML=details.name;
      document.getElementById('box3').innerHTML=details.international_phone_number;    
   });

  }
  google.maps.event.addDomListener(window, 'load', initialize);

  </script>
  </head>
  <body>

  <table>
  <tr><td>Address:</td><td id="box1"></td></tr>
  <tr><td>Name:</td><td id="box2"></td>
  <tr><td>Phone:</td><td id="box3"></td>
  </tr>
  </table>

   <div id="map"></div>
   <div id="text">

</body>
</html>
于 2012-09-26T09:20:02.017 に答える