teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

3

2016/10/12 14:50

投稿

aba623ky
aba623ky

スコア63

title CHANGED
File without changes
body CHANGED
@@ -45,8 +45,8 @@
45
45
 
46
46
  ///下記のphpタグのコードは各店舗の緯度経度がちゃんと入っているか確認するものです。実際入っていました。
47
47
  <?php
48
- echo $r->lng;
48
+ echo $rest->lng;
49
- echo $r->lat;
49
+ echo $rest->lat;
50
50
  ?>
51
51
 
52
52
 

2

緯度経度が間違っていたので訂正します。また、補足があります。

2016/10/12 14:50

投稿

aba623ky
aba623ky

スコア63

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,12 @@
1
1
  コードを全文提示します。
2
2
 
3
+ 写真のようになりました。
4
+
5
+ ![イメージ説明](864d9dcfbb3f0e34e7804a07780b2df1.png)
6
+
3
7
  このように書きました。
8
+
9
+
4
10
  ```
5
11
  <?php
6
12
  $key='My key';
@@ -36,6 +42,14 @@
36
42
 
37
43
 
38
44
  ?>
45
+
46
+ ///下記のphpタグのコードは各店舗の緯度経度がちゃんと入っているか確認するものです。実際入っていました。
47
+ <?php
48
+ echo $r->lng;
49
+ echo $r->lat;
50
+ ?>
51
+
52
+
39
53
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
40
54
  <html>
41
55
  <head>
@@ -45,9 +59,11 @@
45
59
  <script type="text/javascript">
46
60
  google.maps.event.addDomListener(window, 'load', function()
47
61
  {
48
- var lat =35.68944;
62
+ var lat =35.60472;
49
- var lng =139.69167 ;
63
+ var lng =140.12333 ;
50
64
 
65
+
66
+
51
67
  var latlng = new google.maps.LatLng(lat, lng);
52
68
  var mapOptions = {
53
69
  zoom: 12,

1

コードを全文掲示します。

2016/10/12 14:44

投稿

aba623ky
aba623ky

スコア63

title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,84 @@
1
+ コードを全文提示します。
2
+
3
+ このように書きました。
4
+ ```
5
+ <?php
6
+ $key='My key';
7
+ $count='10';
8
+ $large_area='Z014';
9
+ $start =1;
10
+ $format='xml';
11
+ $url='http://webservice.recruit.co.jp/hotpepper/gourmet/v1/?key='.$key.'&count='.$count.'&large_area='.$large_area.'&start='.$start.'&format='.$format;
12
+ $xml=simplexml_load_file($url);
13
+ $total_count=$xml->results_available;
14
+ if(!$xml->shop){
15
+ echo 'We can not find!!';
16
+ } else {
17
+ foreach($xml->shop as $rest){
18
+ echo '<table border="1">';
19
+ echo '<tr>';
20
+ echo '<td>';
21
+ echo $rest->name;
22
+ echo '</td>';
23
+ echo '</tr>';
24
+ echo '<tr class="map">';
25
+ echo '<td>';
26
+ echo $rest->lng;
27
+ echo $rest->lat;
28
+ echo '</td>';
29
+ echo '</tr>';
30
+ echo '<tr>';
31
+ echo '<td>';
32
+ echo $rest->address;
33
+ echo '</td>';
34
+ echo '</tr>';
35
+ echo '</table>';
36
+
37
+
38
+ ?>
39
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
40
+ <html>
41
+ <head>
42
+ <title>Google Maps V3</title>
43
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
44
+ <script type="text/javascript" src="http://maps.google.com/maps/api/js?&sensor=false"></script>
45
+ <script type="text/javascript">
46
+ google.maps.event.addDomListener(window, 'load', function()
47
+ {
48
+ var lat =35.68944;
49
+ var lng =139.69167 ;
50
+
51
+ var latlng = new google.maps.LatLng(lat, lng);
52
+ var mapOptions = {
53
+ zoom: 12,
54
+ center: latlng,
55
+ mapTypeId: google.maps.MapTypeId.ROADMAP,
56
+ scaleControl: true
57
+ };
58
+ var mapObj = new google.maps.Map(document.getElementById('gmap'), mapOptions);
59
+
60
+ var marker = new google.maps.Marker({
61
+ position: {lat:$rest->$lat, lng:$rest->$lng },
62
+ map: mapObj
63
+ });
64
+ });
65
+ </script>
66
+ </head>
67
+ <body>
68
+ <div id="gmap" style="width: 500px; height: 370px; border: 1px solid Gray;">
69
+ </div>
70
+ </body>
71
+ </html>
72
+ <?php
73
+ }
74
+ }
75
+ ?>
76
+ ```
77
+
78
+
79
+
80
+
81
+
1
82
  ホットペーパーapiのレスポンスフィールドの$latと$lng (緯度経度)をgoogle map apiにその値を渡し、地図に位置情報を表したいです。
2
83
 
3
84
  ```php