diff --git a/13100_tokyo23-ku_2020/bldg/conversion.json b/13100_tokyo23-ku_2020/bldg/conversion.json old mode 100644 new mode 100755 diff --git a/13100_tokyo23-ku_2020/bldg/index.geojson b/13100_tokyo23-ku_2020/bldg/index.geojson old mode 100644 new mode 100755 diff --git a/14100_yokohama-shi_2020/bldg/conversion.json b/14100_yokohama-shi_2020/bldg/conversion.json old mode 100644 new mode 100755 diff --git a/14100_yokohama-shi_2020/bldg/index.geojson b/14100_yokohama-shi_2020/bldg/index.geojson old mode 100644 new mode 100755 diff --git a/14100_yokohama-shi_2020/index.geojson b/14100_yokohama-shi_2020/index.geojson old mode 100644 new mode 100755 diff --git a/index.js b/index.js index 582dede..79c40c4 100644 --- a/index.js +++ b/index.js @@ -40,8 +40,9 @@ positioning: 'bottom-center' }); - // 地物オブジェクトを作成 - $.getJSON("index.json", function(data) { + $.when( + $.getJSON("index.json") + ).done(function(data) { site = data.site; $(data.list).each(function() { var feature = new ol.Feature({ @@ -53,37 +54,29 @@ feature.setStyle(style); __markerLayer.getSource().addFeature(feature); }); + + // 地図のクリックイベントを設定 + __map.on('click', function (evt) { + var feature = __map.forEachFeatureAtPixel( + evt.pixel, + function (feature) { + return feature; + } + ); + if (feature) { + var coordinates = feature.getGeometry().getCoordinates(); + var info = feature.information; + var element = __overlay.getElement(); + var descriptionHTML = + "
" + info.code + "
" + + "
" + info.name + "
" + + "
" + info.path + "
"; + element.innerHTML = descriptionHTML; + __overlay.setPosition(coordinates); + __map.addOverlay(__overlay); + } else { + __map.removeOverlay(__overlay); + } + }); }); - - // 地図のクリックイベントを設定 - __map.on('click', function (evt) { - var feature = __map.forEachFeatureAtPixel( - evt.pixel, - function (feature) { - return feature; - } - ); - if (feature) { - var coordinates = feature.getGeometry().getCoordinates(); - var info = feature.information; - var element = __overlay.getElement(); - var descriptionHTML = - "
" + info.code + "
" + - "
" + info.name + "
" + - "
" + info.path + "
"; - element.innerHTML = descriptionHTML; - __overlay.setPosition(coordinates); - __map.addOverlay(__overlay); - } else { - __map.removeOverlay(__overlay); - } - }); - - // ICONをのせるベクターを作成する - /* - var vectorSource = new ol.source.VectorSource({ - url: site + '/data/11230_niiza-shi_2020/bldg/11230_niiza-shi_2020.geojson', - format: new ol.format.GeoJSON() - }) - */ }