Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

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

CSS

              
                #map {
  width: 600px;
  height: 400px;
  margin: auto;
}
              
            
!

JS

              
                //LinkData.orgからのJSONPデータURL
var baseUrl = "http://linkdata.org/api/1/rdf1s804i/temples_in_kyoto_rdf.json?callback=callback";

//緯度・経度データ用オブジェクト
var geoList = {
  lat: [],
  lng: []
};

//JSONデータの取得
getJson(baseUrl);



/************************************************/
//関数
/************************************************/

function getJson(url) {
  var script = document.createElement('script');
  script.src = url;
  document.body.appendChild(script);
  document.body.removeChild(script);
}


//コールバック処理
function callback(data) {
  console.log(data);
  //地図(京都)の表示
  var map = new GMaps({
    el: '#map',
    zoom: 12,
    lat: 35.0336705,
    lng: 135.7664318
  });

  //階層構造のJSONデータを1つずつ読み込む
  for (var i in data) {
    for (var s in data[i]) {
      setGeo(s, data[i]);
    }
  }

  //緯度・経度情報からマーカーを配置
  for (var i = 0; i < geoList.lat.length; i++) {
    map.addMarker({
      lat: geoList.lat[i],
      lng: geoList.lng[i]
    });
  }
};


//JSONデータ内にある緯度・経度を抽出
function setGeo(s, data) {
  if (s.indexOf('#lat') > 0) {
    geoList.lat.push(data[s][0].value);
  } else if (s.indexOf('#long') > 0) {
    geoList.lng.push(data[s][0].value);
  }
}
              
            
!
999px

Console