-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest4.html
More file actions
203 lines (188 loc) · 7.57 KB
/
test4.html
File metadata and controls
203 lines (188 loc) · 7.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<title>OpenLayers.Editor</title>
<script type="text/javascript"
src="http://cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.min.js"></script>
<script src="http://openlayers.org/api/2.13.1/OpenLayers.js"></script>
<!--[if lte IE 6]>
<style>
.customEditingToolbar {
width: 200px;
}
</style>
<![endif]-->
<style>
.customEditingToolbar {
float: right;
right: 0px;
height: 30px;
}
.customEditingToolbar div {
float: right;
margin: 5px;
width: 24px;
height: 24px;
}
.olControlNavigationItemActive {
background-image: url("img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -103px -23px;
}
.olControlNavigationItemInactive {
background-image: url("img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -103px -0px;
}
.olControlDrawFeaturePolygonItemInactive {
background-image: url("img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -26px 0px;
}
.olControlDrawFeaturePolygonItemActive {
background-image: url("img/editing_tool_bar.png");
background-repeat: no-repeat;
background-position: -26px -23px ;
}
.olControlModifyFeatureItemActive {
background-image: url("img/move_feature_on.png");
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlModifyFeatureItemInactive {
background-image: url("img/move_feature_off.png");
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlDeleteFeatureItemActive {
background-image: url("img/remove_point_on.png");
background-repeat: no-repeat;
background-position: 0px 1px;
}
.olControlDeleteFeatureItemInactive {
background-image: url("img/remove_point_off.png");
background-repeat: no-repeat;
background-position: 0px 1px;
}
</style>
<script type="text/javascript">
var map, wfs, styleMap;
//OpenLayers.ProxyHost = "proxy.cgi?url=";
var DeleteFeature = OpenLayers.Class(OpenLayers.Control, {
initialize: function (layer, options) {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
this.layer = layer;
this.handler = new OpenLayers.Handler.Feature(
this, layer, {click: this.clickFeature}
);
},
clickFeature: function (feature) {
console.log(feature);
// if feature doesn't have a fid, destroy it
if (feature.fid == undefined) {
this.layer.destroyFeatures([feature]);
} else {
feature.state = OpenLayers.State.DELETE;
this.layer.events.triggerEvent("afterfeaturemodified",
{feature: feature});
feature.renderIntent = "select";
this.layer.drawFeature(feature);
}
},
setMap: function (map) {
this.handler.setMap(map);
OpenLayers.Control.prototype.setMap.apply(this, arguments);
},
CLASS_NAME: "OpenLayers.Control.DeleteFeature"
});
function init() {
Proj4js.defs['EPSG:2180'] = "+proj=tmerc +lat_0=0 +lon_0=19 +k=0.9993 +x_0=500000 +y_0=-5300000 +ellps=GRS80 +units=m +no_defs";
var geographic = new OpenLayers.Projection("EPSG:2180");
var mercator = new OpenLayers.Projection("EPSG:900913");
// prepare to style the data
styleMap = new OpenLayers.StyleMap({
strokeColor: "black",
strokeWidth: 2,
strokeOpacity: 0.5,
fillOpacity: 0.2
});
var saveStrategy = new OpenLayers.Strategy.Save();
// This server supports server-side reprojection, but we're using WFS 1.0
// here (which doesn't support reprojection) to illustrate client-side
// reprojection.
var wfs = new OpenLayers.Layer.Vector("Nowy Targ", {
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
protocol: new OpenLayers.Protocol.WFS.v1_0_0({
version: "1.0.0",
srsName: "EPSG:2180", // this is the default
url: "http://uslugi.giap.pl/cgi-bin/nowy_targ/qgis_mapserv.fcgi",
featureType: "DZIALKI_EWIDENCYJNE"
}),
projection: geographic, // specified because it is different than the map
styleMap: styleMap,
minScale: 1 / 5000
});
map = new OpenLayers.Map('map', {
projection: mercator,
controls: [
new OpenLayers.Control.PanZoom(),
new OpenLayers.Control.Navigation()
]
});
map.addLayer(new OpenLayers.Layer.OSM());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addLayer(wfs);
var panel = new OpenLayers.Control.Panel({
displayClass: 'customEditingToolbar',
allowDepress: true
});
var draw = new OpenLayers.Control.DrawFeature(
wfs, OpenLayers.Handler.Polygon,
{
title: "Draw Feature",
displayClass: "olControlDrawFeaturePolygon",
multi: true
}
);
var edit = new OpenLayers.Control.ModifyFeature(wfs, {
title: "Modify Feature",
displayClass: "olControlModifyFeature"
});
var del = new DeleteFeature(wfs, {title: "Delete Feature"});
var save = new OpenLayers.Control.Button({
title: "Save Changes",
trigger: function() {
if(edit.feature) {
edit.selectControl.unselectAll();
}
console.log('w save');
saveStrategy.save();
},
displayClass: "olControlSaveFeatures"
});
panel.addControls([save, del, edit, draw]);
map.addControl(panel);
/*// if you want to use Geographic coords, transform to ESPG:900913
var ddBounds = new OpenLayers.Bounds(
-73.839111, 40.287907, -40.214111, 50.441624
);
map.zoomToExtent(
ddBounds.transform(geographic, mercator)
);*/
map.setCenter(new OpenLayers.LonLat(20.03, 49.477778).transform('EPSG:4326', 'EPSG:900913'), 17);
}
</script>
<style type="text/css">
/* Make map consume all available space */
html, body, #map {
height: 100%;
margin: 0;
}
</style>
<link rel="stylesheet" href="../theme/geosilk/geosilk.css" type="text/css"/>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>