このコードがなにを示しているのかお教え頂きたいです。
もしよろしければ、どこを変更すれば汎用的になるかお教え頂きたいです。
(非常に抽象的な質問で申し訳ございません????)
javascript
1 2 //Load XML 3 function load_markers(selected){ 4 $.ajax({ 5 url: 'hinanLocation.xml?date=' + Date.now(), 6 type: 'get',//IEではtextを使用か 7 dataType: 'xml', 8 timeout: 1000, 9 error: function(){ 10 }, 11 success: function(xml,status){ 12 if(status!='success'){ 13 return; 14 }; 15 16 $(xml).find('HinanLoc').each(function(){ 17 var $id = $(this).find('ID').text(); 18 var $name = $(this).find('Name').text(); 19 var $opendate = $(this).find('OpenDate').text(); 20 var $lat = $(this).find('lat').text(); 21 var $lng = $(this).find('lng').text(); 22 var $address = $(this).find('Address').text(); 23 var $tel = $(this).find('Tel').text(); 24 var $capacity = $(this).find('Capacity').text(); 25 var $capacity_text = '避難者数:' + $capacity + '人'; 26 var $status = $(this).find('Status').text(); 27 28 if($status == '開設'){ 29 var $status_class = 'open'; 30 var $status_icon = 'icon_open'; 31 } else if($status == '閉鎖' || $status == '準備中'){ 32 var $status_class = 'closed'; 33 var $status_icon = 'icon_closed'; 34 } else { 35 var $status_class = 'open'; 36 var $status_icon = 'icon_open'; 37 } 38 39 if(!$address) { 40 $address_class = ' hide'; 41 } else { 42 $address_class = ''; 43 } 44 45 if(!$tel) { 46 $tel_class = ' hide'; 47 } else { 48 $tel_class = ''; 49 } 50 51 if(!$capacity) { 52 $capacity_class = ' hide'; 53 } else { 54 $capacity_class = ''; 55 } 56 57 var $icon = new Y.Icon('./images/marker_shelter_'+$status_class+'.png', {iconSize: new Y.Size(36,36)}); 58 var $selected_option = selected; 59 60 //Proj4js.defs["EPSG:3857"] = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +towgs84=0,0,0,0,0,0,0 +nadgrids=@null +wktext +no_defs"; 61 Proj4js.defs["EPSG:2451"] = "+proj=tmerc +lat_0=36 +lon_0=139.8333333333333 +k=0.9999 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"; 62 63 // 変換元の測地系オブジェクト 64 //var source = new Proj4js.Proj('EPSG:3857'); 65 var source = new Proj4js.Proj('EPSG:2451'); 66 // 変換先の測地系オブジェクト 67 var dest = new Proj4js.Proj('EPSG:4326'); 68 // 変換したい座標 69 var p = new Proj4js.Point($lat,$lng); 70 // 測地系変換関数 71 Proj4js.transform(source, dest, p); 72 //alert(p.y + ":" + p.x); 73 74 75 var $marker_name = 'marker_'+$id; 76 var $marker_name = new Y.Marker(new Y.LatLng(p.y, p.x), {icon: $icon}, {title: $name}); 77 var $marker_text = '<h3><span class="status ' + $status_class + '">【' + $status + '】</span>' + $name + '</h3><p class="' + $address_class + '">' + $address + '</p>' + '<a style="text-align:right;" onclick="javascript:ClickHinanjyo(' + $id + ');">詳細</a>'; 78 $marker_name.bindInfoWindow($marker_text); 79 80 if($selected_option == 'all') 81 { 82 ymap.addFeature($marker_name); 83 } 84 else if($selected_option == 'open') 85 { 86 if($status_class == 'open') 87 { 88 ymap.addFeature($marker_name); 89 } 90 } 91 else if($selected_option == 'closed') 92 { 93 if($status_class == 'closed') 94 { 95 ymap.addFeature($marker_name); 96 } 97 } 98 }); 99 } 100 }); 101 }
回答1件
あなたの回答
tips
プレビュー