これは駄目だ。。本家(google)に勝てない。あかんわ。
<?php $uri = "http://api.gnavi.co.jp/RestSearchAPI/20150630/"; $acckey = "donot watch"; $format="json"; $lat = 35.6952455; $lon = 139.704177; $range = 2; $url = sprintf("%s%s%s%s%s%s%s%s%s%s%s%s", $uri, "?format=", $format, "&keyid=", $acckey, "&latitude=", $lat,"&longitude=",$lon,"&range=",$range,"&hit_per_page=100"); // print_r($url); $json = file_get_contents($url); $obj = json_decode($json); foreach($obj->rest as $value){ $name[] = $value->name; $cate[] = $value->category; $glat[] = $value->latitude; $glng[] = $value->longitude; $gurl[] = $value->url; } // print_r('<pre>'); // var_dump($obj); // print_r('</pre>'); $glat = json_encode($glat); $glng = json_encode($glng); $shop = json_encode($name); $cate = json_encode($cate); $url = json_encode($gurl); ?> <style> #ginza { height: 70%; width: 100%; font-size:small; } html, body { height: 100%; margin: 0; padding: 0; } </style> 繁華街<br> 新宿 歌舞伎町 風鈴会館周辺 <div id="ginza"></div> <script> var map; var marker = []; var infoWindow = []; var icon00 = 'img/00.png';var icon01 = 'img/01.png';var icon02 = 'img/02.png';var icon03 = 'img/03.png';var icon04 = 'img/04.png';var icon05 = 'img/05.png';var icon06 = 'img/06.png';var icon07 = 'img/07.png';var icon08 = 'img/08.png';var icon09 = 'img/09.png';var icon10 = 'img/10.png';var icon11 = 'img/11.png';var icon12 = 'img/12.png';var icon13 = 'img/13.png';var icon14 = 'img/14.png';var icon15 = 'img/15.png';var icon16 = 'img/16.png';var icon17 = 'img/17.png';var icon18 = 'img/18.png';var icon19 = 'img/19.png';var icon20 = 'img/20.png';var icon21 = 'img/21.png'; function initMap(){ var mapLatLng = new google.maps.LatLng({ lat: <?php echo $lat; ?>, lng: <?php echo $lon; ?>}); map = new google.maps.Map(document.getElementById('ginza'),{ center: mapLatLng, zoom: 19 }); var lat_array = JSON.parse('<?php echo $glat; ?>'); var lng_array = JSON.parse('<?php echo $glng; ?>'); var shop = JSON.parse('<?php echo $shop; ?>'); var cate = JSON.parse('<?php echo $cate; ?>'); var url = JSON.parse('<?php echo $url; ?>'); console.log(lng_array); for(var i=0; i < 101; i++){ markerLatLng = new google.maps.LatLng({lat: Number(lat_array[i]), lng: Number(lng_array[i])}); marker[i] = new google.maps.Marker({ position: markerLatLng, label: shop[i], map: map }); infoWindow[i] = new google.maps.InfoWindow({ content: '<a href="' + url[i]+ '">' + shop[i] + '</a>' }); switch (cate[i]){ case '居酒屋':case'日本酒バー':case'晩酌居酒屋':case'和食寿司居酒屋/酒場':marker[i].setOptions({icon: {url: icon00}});break; case 'カフェ':marker[i].setOptions({icon: {url: icon01}});break; case 'バー':case'ワイン':case'パワーストーンバー':case'ダイニングバー':case'大人の隠れ家バー':case'カフェダイニング バー':case'シャンパン・ワイン':marker[i].setOptions({icon: {url: icon02}});break; case 'そば':marker[i].setOptions({icon: {url: icon03}});break; case 'ラーメン':marker[i].setOptions({icon: {url: icon04}});break; case '日本料理':case'創作料理':case'旬の串揚げ・和食':case'小料理':case'鮨 和食':case'鮨 和食':marker[i].setOptions({icon: {url: icon05}});break; case '寿司':case'寿司屋':marker[i].setOptions({icon: {url: icon06}});break; case '天ぷら':marker[i].setOptions({icon: {url: icon07}});break; case '海鮮料理':marker[i].setOptions({icon: {url: icon08}});break; case 'おでん':case'焼鳥 鶏料理':case'焼き鳥':marker[i].setOptions({icon: {url: icon09}});break; case 'お好み焼き':marker[i].setOptions({icon: {url: icon10}});break; case 'カレー':marker[i].setOptions({icon: {url: icon11}});break; case 'イタリアン':case'薪焼きイタリアン':marker[i].setOptions({icon: {url: icon12}});break; case '中華料理':marker[i].setOptions({icon: {url: icon13}});break; case 'タイ料理':case'ベトナム料理':case'ネパール料理':marker[i].setOptions({icon: {url: icon14}});break; case 'フレンチ':case'ビストロ':case'ワインビストロ':case'フレンチ ビストロ':case'鉄板焼きダイニング':case'フレンチレストラン':marker[i].setOptions({icon: {url: icon15}});break; case '焼肉':case'野菜×鉄板焼き':case'ホルモン':case'鉄板鍋・牛タン・ワイン':marker[i].setOptions({icon: {url: icon16}});break; case 'ハンバーガー':marker[i].setOptions({icon: {url: icon17}});break; case 'デザート':case'和菓子':case'パンケーキカフェ':marker[i].setOptions({icon: {url: icon18}});break; default:marker[i].setOptions({icon: {url: icon19}});break; } markerEvent(i); } } function markerEvent(i){ marker[i].addListener('click', function(){ infoWindow[i].open(map, marker[i]); }); } </script>