Map visualization/popup with Django and Leaflet












0














enter image description hereI am new to Django and I am struggling with a problem for many weeks. My template/html page works fine with leaflet, but when I run the template on Django it doesnt load my map (geoJson file). I have tried watching all the tutorials but no luck. Could anyone please help? I have uploaded a picture which comes alright using only leaflet and html, but comes blank on Django server.



Below is my code:



[![<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content = "width=device-width,initial-scale=1"/>
<title>
Map Visualization
</title>
<!-- Leaflet -->
<link rel= "stylesheet" href="../../leaflet/leaflet.css"/>
<script src = "../../leaflet/leaflet.js"></script>
<script src ="../data/countries.geojson"></script>
<style type = "text/css">
#map {
height : 800px;
width: 70%;
align: left
}

#filter {
height:800px;
width: 20%
align: right
}
</style>

</head>
<body>
<h1 style="color:green;"> Map Visualization </h1>
<div id="map"></div>


<script>
function getStateColor(stateShade){
if (stateShade =="colored-state"){
return '#6666ff';
}else if(stateShade!="non-colored-state"){
return '#D3D3D3';
}
}

function countriesStyle(feature){
return {
fillColor : getStateColor(feature.properties.shade),
weight : 2,
opacity : 1,
color: 'white',
dashArray : 2.5,
fillOpacity :0.7
}
}

var map = L.map('map').setView([80, 30], 19)
var countriesLayer = L.geoJson(
countries,
{style : countriesStyle}
).addTo(map);
map.fitBounds(countriesLayer.getBounds());

var point1 =[44.066803,-93.533061];
var point2 = [43.064,-89.5347];

var marker1 = L.marker(point1).addTo(map).bindPopup("<p>State: MN" );
var marker2 = L.marker(point2).addTo(map).bindPopup("<p>State:WI" );

</script>
</body>

</html>][1]][1]









share|improve this question






















  • Some log on console?
    – dani herrera
    Nov 20 at 17:37
















0














enter image description hereI am new to Django and I am struggling with a problem for many weeks. My template/html page works fine with leaflet, but when I run the template on Django it doesnt load my map (geoJson file). I have tried watching all the tutorials but no luck. Could anyone please help? I have uploaded a picture which comes alright using only leaflet and html, but comes blank on Django server.



Below is my code:



[![<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content = "width=device-width,initial-scale=1"/>
<title>
Map Visualization
</title>
<!-- Leaflet -->
<link rel= "stylesheet" href="../../leaflet/leaflet.css"/>
<script src = "../../leaflet/leaflet.js"></script>
<script src ="../data/countries.geojson"></script>
<style type = "text/css">
#map {
height : 800px;
width: 70%;
align: left
}

#filter {
height:800px;
width: 20%
align: right
}
</style>

</head>
<body>
<h1 style="color:green;"> Map Visualization </h1>
<div id="map"></div>


<script>
function getStateColor(stateShade){
if (stateShade =="colored-state"){
return '#6666ff';
}else if(stateShade!="non-colored-state"){
return '#D3D3D3';
}
}

function countriesStyle(feature){
return {
fillColor : getStateColor(feature.properties.shade),
weight : 2,
opacity : 1,
color: 'white',
dashArray : 2.5,
fillOpacity :0.7
}
}

var map = L.map('map').setView([80, 30], 19)
var countriesLayer = L.geoJson(
countries,
{style : countriesStyle}
).addTo(map);
map.fitBounds(countriesLayer.getBounds());

var point1 =[44.066803,-93.533061];
var point2 = [43.064,-89.5347];

var marker1 = L.marker(point1).addTo(map).bindPopup("<p>State: MN" );
var marker2 = L.marker(point2).addTo(map).bindPopup("<p>State:WI" );

</script>
</body>

</html>][1]][1]









share|improve this question






















  • Some log on console?
    – dani herrera
    Nov 20 at 17:37














0












0








0







enter image description hereI am new to Django and I am struggling with a problem for many weeks. My template/html page works fine with leaflet, but when I run the template on Django it doesnt load my map (geoJson file). I have tried watching all the tutorials but no luck. Could anyone please help? I have uploaded a picture which comes alright using only leaflet and html, but comes blank on Django server.



Below is my code:



[![<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content = "width=device-width,initial-scale=1"/>
<title>
Map Visualization
</title>
<!-- Leaflet -->
<link rel= "stylesheet" href="../../leaflet/leaflet.css"/>
<script src = "../../leaflet/leaflet.js"></script>
<script src ="../data/countries.geojson"></script>
<style type = "text/css">
#map {
height : 800px;
width: 70%;
align: left
}

#filter {
height:800px;
width: 20%
align: right
}
</style>

</head>
<body>
<h1 style="color:green;"> Map Visualization </h1>
<div id="map"></div>


<script>
function getStateColor(stateShade){
if (stateShade =="colored-state"){
return '#6666ff';
}else if(stateShade!="non-colored-state"){
return '#D3D3D3';
}
}

function countriesStyle(feature){
return {
fillColor : getStateColor(feature.properties.shade),
weight : 2,
opacity : 1,
color: 'white',
dashArray : 2.5,
fillOpacity :0.7
}
}

var map = L.map('map').setView([80, 30], 19)
var countriesLayer = L.geoJson(
countries,
{style : countriesStyle}
).addTo(map);
map.fitBounds(countriesLayer.getBounds());

var point1 =[44.066803,-93.533061];
var point2 = [43.064,-89.5347];

var marker1 = L.marker(point1).addTo(map).bindPopup("<p>State: MN" );
var marker2 = L.marker(point2).addTo(map).bindPopup("<p>State:WI" );

</script>
</body>

</html>][1]][1]









share|improve this question













enter image description hereI am new to Django and I am struggling with a problem for many weeks. My template/html page works fine with leaflet, but when I run the template on Django it doesnt load my map (geoJson file). I have tried watching all the tutorials but no luck. Could anyone please help? I have uploaded a picture which comes alright using only leaflet and html, but comes blank on Django server.



Below is my code:



[![<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content = "width=device-width,initial-scale=1"/>
<title>
Map Visualization
</title>
<!-- Leaflet -->
<link rel= "stylesheet" href="../../leaflet/leaflet.css"/>
<script src = "../../leaflet/leaflet.js"></script>
<script src ="../data/countries.geojson"></script>
<style type = "text/css">
#map {
height : 800px;
width: 70%;
align: left
}

#filter {
height:800px;
width: 20%
align: right
}
</style>

</head>
<body>
<h1 style="color:green;"> Map Visualization </h1>
<div id="map"></div>


<script>
function getStateColor(stateShade){
if (stateShade =="colored-state"){
return '#6666ff';
}else if(stateShade!="non-colored-state"){
return '#D3D3D3';
}
}

function countriesStyle(feature){
return {
fillColor : getStateColor(feature.properties.shade),
weight : 2,
opacity : 1,
color: 'white',
dashArray : 2.5,
fillOpacity :0.7
}
}

var map = L.map('map').setView([80, 30], 19)
var countriesLayer = L.geoJson(
countries,
{style : countriesStyle}
).addTo(map);
map.fitBounds(countriesLayer.getBounds());

var point1 =[44.066803,-93.533061];
var point2 = [43.064,-89.5347];

var marker1 = L.marker(point1).addTo(map).bindPopup("<p>State: MN" );
var marker2 = L.marker(point2).addTo(map).bindPopup("<p>State:WI" );

</script>
</body>

</html>][1]][1]






django leaflet geojson






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 17:33









natg

578




578












  • Some log on console?
    – dani herrera
    Nov 20 at 17:37


















  • Some log on console?
    – dani herrera
    Nov 20 at 17:37
















Some log on console?
– dani herrera
Nov 20 at 17:37




Some log on console?
– dani herrera
Nov 20 at 17:37

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398471%2fmap-visualization-popup-with-django-and-leaflet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398471%2fmap-visualization-popup-with-django-and-leaflet%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Ottavio Pratesi

Tricia Helfer

15 giugno