forked from GeoNode/geonode
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bug fix embed widget, the previous code still encountered problem with CORS * fix travis error * embed widget link for qgis-server and geoserver backend * embed widget link and add copy button * refactor map projection on the frontend into django views fix #152
- Loading branch information
Showing
6 changed files
with
159 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<div class="map-container"> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.css"/> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.3/leaflet.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4-src.js"></script> | ||
<script type="text/javascript"> | ||
$(document).ready(function () { | ||
var wmsLayer = null; | ||
|
||
var map = L.map('map').setView([{{ resource.center_y }}, {{ resource.center_x }}], {{ resource.zoom }}); | ||
var osm = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { | ||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors', | ||
}); | ||
map.addLayer(osm); | ||
|
||
var bbox = {{ map_bbox }}; | ||
|
||
zoom_to_box(map, bbox); | ||
|
||
{% for layer in map_layers %} | ||
var layer_url = '{{ layer.ows_url }}'; | ||
var options = { | ||
format: 'image/png', | ||
transparent: true, | ||
layers: '{{ layer.name }}', | ||
opacity: 0.8 | ||
}; | ||
if (layer_url.includes('{z}') && layer_url.includes('{y}') && layer_url.includes('{x}')) { | ||
wmsLayer = L.tileLayer(layer_url, options); | ||
} | ||
else { | ||
wmsLayer = L.tileLayer.wms(layer_url, options); | ||
} | ||
if (wmsLayer != null) { | ||
map.addLayer(wmsLayer); | ||
} | ||
{% endfor %} | ||
}); | ||
|
||
function zoom_to_box(map, bbox) { | ||
var bounds = [ | ||
[bbox[1], bbox[0]], | ||
[bbox[3], bbox[2]] | ||
]; | ||
} | ||
</script> | ||
<style type="text/css"> | ||
#map { | ||
height: 800px; | ||
} | ||
</style> | ||
<div id="map"></div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.