在扩展模板django中使用时,leaflet_map不起作用

时间:2019-03-31 03:39:13

标签: django django-templates leaflet template-inheritance django-leaflet

我正在使用django-leaflet来显示在我的网站上,并且当我在基本模板中包含leaflet_map时,它可以正常工作并在浏览器上显示地图,但是当我在扩展该基本模板的模板上使用leaflet_map时,地图却无法显示” t出现在浏览器中。

这是来自base.html的扩展模板的代码,它不会在浏览器上显示地图。

#First, we'll create a fake dataset of 20 individuals of different body sizes:
bodysize=rnorm(20,30,2) # generates 20 values, with mean of 30 & s.d.=2
bodysize=sort(bodysize) # sorts these values in ascending order. 
survive=c(0,0,0,0,0,1,0,1,0,0,1,1,0,1,1,1,0,1,1,1) # assign 'survival' to these 20 individuals non-randomly... most mortality occurs at smaller body size
dat=as.data.frame(cbind(bodysize,survive)) # saves dataframe with two columns: 
body size & survival
dat # just shows you what your dataset looks like. It will look something like this:
plot(bodysize,survive,xlab="Body size",ylab="Probability of survival") # plot with body size on x-axis and survival (0 or 1) on y-axis
g=glm(survive~bodysize,family=binomial,dat) # run a logistic regression model (in this case, generalized linear model with logit link). see ?glm

curve(predict(g,data.frame(bodysize=x),type="resp"),add=TRUE) # draws a curve based on prediction from logistic regression model

points(bodysize,fitted(g),pch=20) # optional: you could skip this draws an 
invisible set of points of body size survival based on a 'fit' to glm model. 
pch= changes type of dots.

这些是基础模板的片段。

   {% extends 'base.html' %}
   {% load leaflet_tags %}

   {% block leaflet %}{% leaflet_js %}{% leaflet_css %}{% endblock %}



{% block content %}
  {% leaflet_map 'gis' %}
{% endblock content%}

0 个答案:

没有答案