Language
Login
Language Setting
X
English
日本語 [Japanese]
about this App
長野市の小中学校と防犯MAP
useful
5
Loading...
/* This is a Example program to retrieve and display the data. Press the Run button on the right of the screen (described the behavior of the Example program below). Please create a new application rewrite this program work. */ var all_data; function initialize(){ all_data = new Array(); all2_data = new Array(); // データをLinkDataから取得 tmp_a_data = new Array(); tmp_b_data = new Array(); $.each(LinkData.getWorks(), function(workKey, workValue) { //$("#result").append("<h3>Work: " + workValue + "</h3>"); $.each(LinkData.getFiles(workValue), function(fileKey, fileValue) { $.each(LinkData.getSubjects(workValue, fileValue), function(subjKey, subjValue) { var tmp_data = {} tmp_data["name"] = subjValue; $.each(LinkData.getProperties(workValue, fileValue), function(propKey, propValue) { $.each(LinkData.getObjects(workValue, fileValue, subjValue, propValue), function(objKey, objValue) { var tmp_name = propValue.split("#"); if(tmp_name[1] == "lat"){ tmp_data["lat"] = parseFloat(objValue); } else if(tmp_name[1] == "lng" || tmp_name[1] == "long"){ tmp_data["lng"] = parseFloat(objValue); } else if(tmp_name[1] == "zip"){ tmp_data["zip"] = objValue; } else if(tmp_name[1] == "tel"){ tmp_data["tel"] = objValue; } else if(tmp_name[1] == "address"){ tmp_data["address"] = objValue; } else if(tmp_name[1] == "kubun"){ tmp_data["kubun"] = objValue; } }); }); //console.log(tmp_data); if(fileValue === "school_in_nagano"){ tmp_a_data.push(tmp_data); } else { tmp_b_data.push(tmp_data); } }); }); }); //全データ all_data = tmp_a_data; all_data2 = tmp_b_data; //全データを地図上に表示 // 地図センター緯度経度の初期値は「長野市役所」 var latlng = new google.maps.LatLng(36.6491119,138.168098); var myOptions = { zoom: 12, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("result"), myOptions); // ウィンドウに表示するデータをつくる var data = new Array(); for (var i in all_data){ var value = decodeURI(all_data[i].name); var tmp_name = value.split("#"); var point_name = tmp_name[1]; //console.log(all_data[i].lat, all_data[i].lng) data.push({position: new google.maps.LatLng(all_data[i].lat, all_data[i].lng), content: point_name }); }; // 地図上にウィンドウで表示 for (i = 0; i < data.length; i++) { var icon = "http://app.linkdata.org/asset/e7d97693.png"; if(all_data[i].kubun === "2"){ icon = "http://app.linkdata.org/asset/173688d7.png"; } var marker = new google.maps.Marker({ position: data[i].position, map: map, icon: icon }); attachMessage(marker, data[i].content); }; // ウィンドウに表示するデータをつくる var data2 = new Array(); for (var i in all_data2){ var value = decodeURI(all_data2[i].name); var tmp_name = value.split("#"); var point_name = tmp_name[1]; //console.log(all_data[i].lat, all_data[i].lng) var content = point_name + "<br>" + all_data2[i].zip + "<br>" + all_data2[i].address + "<br>" + all_data2[i].tel; data2.push({position: new google.maps.LatLng(all_data2[i].lat, all_data2[i].lng), content: content }); }; // 地図上にウィンドウで表示 for (i = 0; i < data2.length; i++) { var marker = new google.maps.Marker({ position: data2[i].position, map: map, icon: "http://app.linkdata.org/asset/ebdea505.png" }); attachMessage(marker, data2[i].content); var color = "#00ff00"; var radius = 1000; if (data2[i].content.match(/^長野中央警察署/) || data2[i].content.match(/^長野南警察署/)){ color = "#0000ff"; radius = 2000; } new google.maps.Circle({ center: data2[i].position, // 中心点(google.maps.LatLng) fillColor: color, // 塗りつぶし色 fillOpacity: 0.5, // 塗りつぶし透過度(0: 透明 ⇔ 1:不透明) map: map, // 表示させる地図(google.maps.Map) radius: radius, // 半径(m) strokeColor: color, // 外周色 strokeOpacity: 1, // 外周透過度(0: 透明 ⇔ 1:不透明) strokeWeight: 1 // 外周太さ(ピクセル) }); }; }; // 地図のマーカーをクリックするとウィンドウを表示する処理 function attachMessage(marker, msg) { google.maps.event.addListener(marker, 'click', function(event) { new google.maps.InfoWindow({ content: msg }).open(marker.getMap(), marker); }); }; window.onload = function() { $(function(){ initialize(); }); };
<style type="text/css"> html { height: 100% } body { height: 100%; margin: 0; padding: 0 } #map_canvas { height: 100% } </style> <div id="result" style="width:100%; height:100%"></div>
Preview
Input Data
ReadMe
Snapshots
LinkData Work
Table Data
長野市の交番・駐在所
Contributor:Takumi Aizu
Update:Feb 22, 2015
215 Downloads, 1 Applications
長野市の交番・駐在所の一覧
koban_in_nagano
[
]
長野市の小中学校
Contributor:Takumi Aizu
Update:Feb 21, 2015
279 Downloads, 1 Applications
長野市の小中学校の一覧
school_in_nagano
Add LinkData work(LinkData)
Link http://app.linkdata.org/run/app1s950i?tab=readme
Initial content
jquery-1.7.1.min.js
http://maps.googleapis.com/maps/api/js?sensor=false
Work
Add
Clear
insert work id or work name.