1
JavaScriptやAPIのプログラミングに関する知識がなくても、この例を自分のニーズに合わせるためにいくつかの問題があります。select GitHub repo 私はこのAPIを使用するためにそれを適応させようとしています:https://api-adresse.data.gouv.fr/search/? 。selectize.jsとShiny:リモートAPIから選択肢を選択
応答はGeoJSONファイルで、機能は応答$機能に格納されます。私は、各機能のプロパティ$ label属性を取得したいと思います。
ここまでは私がこれまで行ってきたことです。私は配列を取得しますがアイテムをドロップダウンに表示されていない...
UI:
########
# ui.R #
########
library(shiny)
fluidPage(
title = 'Selectize examples',
mainPanel(
selectizeInput('addresses', 'Select address', choices = '', options = list(
valueField = 'properties.label',
labelField = 'properties.label',
searchField = 'properties.label',
options = list(),
create = FALSE,
render = I("
{
option: function(item, escape) {
return '<div>' + '<strong>' + escape(item.properties.name) + '</strong>' + '</div>';
}
}" ),
load = I("
function(query, callback) {
if (!query.length) return callback();
$.ajax({
url: 'https://api-adresse.data.gouv.fr/search/?',
type: 'GET',
data: {
q: query
},
dataType: 'json',
error: function() {
callback();
},
success: function(res) {
console.log(res.features);
callback(res.features);
}
});
}"
)
))
)
)
サーバー:
############
# server.R #
############
library(shiny)
function(input, output) {
output$github <- renderText({
paste('You selected', if (input$github == '') 'nothing' else input$github,
'in the Github example.')
})
}
あなたの助けをいただき、ありがとうございます。