2017-08-24 4 views
1

Utilisation de python J'essaie de construire une carte avec des marqueurs en utilisant Folium. Cela fonctionne très bien, mais maintenant j'ai commencé à essayer d'ajouter des graphiques plot.ly dans la carte qui ne fonctionne pas bien. Est-il impossible d'avoir javascript à l'intérieur des fenêtres pop-up (Folium)?combine plotly et folium

Le code js qui est dans le fichier html est indiqué ci-dessous:

var marker_7ecf53df703f455c9b8e9342784a4fde = L.marker([-30.0,31.25], { 
      icon: new L.Icon.Default() 
     } 
    ).addTo(map_698b07e412264d16ab4a7628d18d6a7a); 


var popup_d63d578364d04568bda1b68bc0a870d7 = L.popup({maxWidth: '300'}); 

var html_deaec1fcc80d483faff605dcfa6691ff = $('<div id="html_deaec1fcc80d483faff605dcfa6691ff" style="width: 100.0%; height: 100.0%;"><div id="5be3c360-6f61-47fc-af22-c43d8a2c16ed" style="height: 100%; width: 100%;" class="plotly-graph-div"></div><script type="text/javascript">window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL="https://plot.ly";Plotly.newPlot("5be3c360-6f61-47fc-af22-c43d8a2c16ed", [{"marker": {"color": "rgb(106,81,163)"}, "r": [77.5, 72.5, 70.0, 45.0, 22.5, 42.5, 40.0, 62.5], "type": "area", "name": "11-14 m/s", "t": [0, 45, 90, 135, 180, 225, 270, 315]}], {"radialaxis": {"ticksuffix": "%"}, "title": "Wind Speed Distribution in Laurel, NE", "font": {"size": 16}, "orientation": 270, "legend": {"font": {"size": 16}}}, {"linkText": "Export to plot.ly", "showLink": true})</script></div>')[0]; 

popup_d63d578364d04568bda1b68bc0a870d7.setContent(html_deaec1fcc80d483faff605dcfa6691ff); 

marker_7ecf53df703f455c9b8e9342784a4fde.bindPopup(popup_d63d578364d04568bda1b68bc0a870d7); 

I comprennent les popups comme par exemple:

for rowNum, rowValues in data.iterrows(): 
    popup = folium.Html(polarHtml, script=True) # polarHtml is the html 
    folium.Marker([rowValues['latitude'], rowValues['longitude']], popup=folium.Popup(popup)).add_to(map_osm) 

La carte fonctionne très bien si je viens d'utiliser le HTML simple à l'intérieur du popups. Est-ce que quelqu'un sait où cela va mal?

Répondre

1

Je l'ai "résolu" à la fin. Bien que je ne suis pas un grand fan d'IFrames, j'ai fini par combiner folium.HTML et folium.IFrame comme suit:

folium.Popup(folium.Html('aa<br>'+folium.IFrame(polarHtml, width='410px', height='410px').render(), script=True), max_width=2650)