我正在使用GeoJSON作为Google地图的数据源.我正在使用API的v3来创建数据层,如下所示:
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
var map;
function initialize() {
//Initialise the map
var myLatLng = new google.maps.LatLng(53.231472,-0.539783);
map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 17,
center: myLatLng,
scrollwheel: false,
panControl: false,
zoomControl: false,
scaleControl: true,
disableDefaultUI: true
});
//Initialise base folder for icons
var iconBase = '/static/images/icons/';
//Load the JSON to show places
map.data.loadGeoJson('/api/geo');
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="map-canvas"></div>
Run Code Online (Sandbox Code Playgroud)
我的GeoJSON数据的来源如下:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"icon": "/static/images/icons/map-marker-do.png",
"coordinates": [
-0.53743,
53.23437
] …Run Code Online (Sandbox Code Playgroud) 我想使用类实例作为字典键,如:
classinstance = class()
dictionary[classinstance] = 'hello world'
Run Code Online (Sandbox Code Playgroud)
Python似乎无法将类作为字典键处理,或者我错了?另外,我可以使用像[(classinstance,helloworld),...]这样的元组列表而不是字典,但这看起来非常不专业.你有解决这个问题的线索吗?
在使用pyLDAvis.sklearn.prepare可视化LDA主题模型时,遇到以下错误消息:
>>> pyLDAvis.sklearn.prepare(lda_model, dtm, vectorizer)
...
---> 12 return dtm.sum(axis=1).getA1()
...
AttributeError: 'numpy.ndarray' object has no attribute 'getA1'
Run Code Online (Sandbox Code Playgroud)
dtm作为pyLDAvis.sklearn.preparea传递pd.DataFrame会引发类似的错误:
AttributeError: 'Series' object has no attribute 'getA1'
Run Code Online (Sandbox Code Playgroud)
为什么会出现此错误消息?
python ×2
dictionary ×1
google-maps ×1
javascript ×1
json ×1
list ×1
numpy ×1
pandas ×1
pyldavis ×1
tuples ×1