Reformatted slightly openlayers.js
This commit is contained in:
parent
6a91b63842
commit
f3d1aebed1
|
@ -10,19 +10,21 @@ OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.Sp
|
||||||
{{ module }}.is_polygon = {{ is_polygon|yesno:"true,false" }};
|
{{ module }}.is_polygon = {{ is_polygon|yesno:"true,false" }};
|
||||||
{{ module }}.is_point = {{ is_point|yesno:"true,false" }};
|
{{ module }}.is_point = {{ is_point|yesno:"true,false" }};
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{{ module }}.get_ewkt = function(feat){return 'SRID={{ srid }};' + {{ module }}.wkt_f.write(feat);}
|
{{ module }}.get_ewkt = function(feat){
|
||||||
|
return 'SRID={{ srid }};' + {{ module }}.wkt_f.write(feat);
|
||||||
|
};
|
||||||
{{ module }}.read_wkt = function(wkt){
|
{{ module }}.read_wkt = function(wkt){
|
||||||
// OpenLayers cannot handle EWKT -- we make sure to strip it out.
|
// OpenLayers cannot handle EWKT -- we make sure to strip it out.
|
||||||
// EWKT is only exposed to OL if there's a validation error in the admin.
|
// EWKT is only exposed to OL if there's a validation error in the admin.
|
||||||
var match = {{ module }}.re.exec(wkt);
|
var match = {{ module }}.re.exec(wkt);
|
||||||
if (match){wkt = match[1];}
|
if (match){wkt = match[1];}
|
||||||
return {{ module }}.wkt_f.read(wkt);
|
return {{ module }}.wkt_f.read(wkt);
|
||||||
}
|
};
|
||||||
{{ module }}.write_wkt = function(feat){
|
{{ module }}.write_wkt = function(feat){
|
||||||
if ({{ module }}.is_collection){ {{ module }}.num_geom = feat.geometry.components.length;}
|
if ({{ module }}.is_collection){ {{ module }}.num_geom = feat.geometry.components.length;}
|
||||||
else { {{ module }}.num_geom = 1;}
|
else { {{ module }}.num_geom = 1;}
|
||||||
document.getElementById('{{ id }}').value = {{ module }}.get_ewkt(feat);
|
document.getElementById('{{ id }}').value = {{ module }}.get_ewkt(feat);
|
||||||
}
|
};
|
||||||
{{ module }}.add_wkt = function(event){
|
{{ module }}.add_wkt = function(event){
|
||||||
// This function will sync the contents of the `vector` layer with the
|
// This function will sync the contents of the `vector` layer with the
|
||||||
// WKT in the text field.
|
// WKT in the text field.
|
||||||
|
@ -41,7 +43,7 @@ OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.Sp
|
||||||
}
|
}
|
||||||
{{ module }}.write_wkt(event.feature);
|
{{ module }}.write_wkt(event.feature);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
{{ module }}.modify_wkt = function(event){
|
{{ module }}.modify_wkt = function(event){
|
||||||
if ({{ module }}.is_collection){
|
if ({{ module }}.is_collection){
|
||||||
if ({{ module }}.is_point){
|
if ({{ module }}.is_point){
|
||||||
|
@ -59,27 +61,31 @@ OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.Sp
|
||||||
} else {
|
} else {
|
||||||
{{ module }}.write_wkt(event.feature);
|
{{ module }}.write_wkt(event.feature);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
// Function to clear vector features and purge wkt from div
|
// Function to clear vector features and purge wkt from div
|
||||||
{{ module }}.deleteFeatures = function(){
|
{{ module }}.deleteFeatures = function(){
|
||||||
{{ module }}.layers.vector.removeFeatures({{ module }}.layers.vector.features);
|
{{ module }}.layers.vector.removeFeatures({{ module }}.layers.vector.features);
|
||||||
{{ module }}.layers.vector.destroyFeatures();
|
{{ module }}.layers.vector.destroyFeatures();
|
||||||
}
|
};
|
||||||
{{ module }}.clearFeatures = function (){
|
{{ module }}.clearFeatures = function (){
|
||||||
{{ module }}.deleteFeatures();
|
{{ module }}.deleteFeatures();
|
||||||
document.getElementById('{{ id }}').value = '';
|
document.getElementById('{{ id }}').value = '';
|
||||||
{% localize off %}
|
{% localize off %}
|
||||||
{{ module }}.map.setCenter(new OpenLayers.LonLat({{ default_lon }}, {{ default_lat }}), {{ default_zoom }});
|
{{ module }}.map.setCenter(new OpenLayers.LonLat({{ default_lon }}, {{ default_lat }}), {{ default_zoom }});
|
||||||
{% endlocalize %}
|
{% endlocalize %}
|
||||||
}
|
};
|
||||||
// Add Select control
|
// Add Select control
|
||||||
{{ module }}.addSelectControl = function(){
|
{{ module }}.addSelectControl = function(){
|
||||||
var select = new OpenLayers.Control.SelectFeature({{ module }}.layers.vector, {'toggle' : true, 'clickout' : true});
|
var select = new OpenLayers.Control.SelectFeature({{ module }}.layers.vector, {'toggle' : true, 'clickout' : true});
|
||||||
{{ module }}.map.addControl(select);
|
{{ module }}.map.addControl(select);
|
||||||
select.activate();
|
select.activate();
|
||||||
}
|
};
|
||||||
{{ module }}.enableDrawing = function(){ {{ module }}.map.getControlsByClass('OpenLayers.Control.DrawFeature')[0].activate();}
|
{{ module }}.enableDrawing = function(){
|
||||||
{{ module }}.enableEditing = function(){ {{ module }}.map.getControlsByClass('OpenLayers.Control.ModifyFeature')[0].activate();}
|
{{ module }}.map.getControlsByClass('OpenLayers.Control.DrawFeature')[0].activate();
|
||||||
|
};
|
||||||
|
{{ module }}.enableEditing = function(){
|
||||||
|
{{ module }}.map.getControlsByClass('OpenLayers.Control.ModifyFeature')[0].activate();
|
||||||
|
};
|
||||||
// Create an array of controls based on geometry type
|
// Create an array of controls based on geometry type
|
||||||
{{ module }}.getControls = function(lyr){
|
{{ module }}.getControls = function(lyr){
|
||||||
{{ module }}.panel = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
|
{{ module }}.panel = new OpenLayers.Control.Panel({'displayClass': 'olControlEditingToolbar'});
|
||||||
|
@ -102,7 +108,7 @@ OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.Sp
|
||||||
{{ module }}.controls = [nav];
|
{{ module }}.controls = [nav];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
{{ module }}.init = function(){
|
{{ module }}.init = function(){
|
||||||
{% block map_options %}// The options hash, w/ zoom, resolution, and projection settings.
|
{% block map_options %}// The options hash, w/ zoom, resolution, and projection settings.
|
||||||
var options = {
|
var options = {
|
||||||
|
@ -171,4 +177,4 @@ OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857", OpenLayers.Layer.Sp
|
||||||
} else {
|
} else {
|
||||||
{{ module }}.enableDrawing();
|
{{ module }}.enableDrawing();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
Loading…
Reference in New Issue