|
5 | 5 | <title>Open Layers Street Smart Example</title>
|
6 | 6 | <meta charset="utf-8" />
|
7 | 7 | <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.css">
|
8 |
| - <link rel="stylesheet" href="https://unpkg.com/openlayers@4.6.5/dist/ol.css" type="text/css"> |
| 8 | + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@v10.6.0/ol.css"> |
9 | 9 | <style>
|
10 | 10 | body {
|
11 | 11 | display: flex;
|
|
61 | 61 |
|
62 | 62 | <script type="text/javascript" src="https://unpkg.com/react@18.2.0/umd/react.production.min.js"></script>
|
63 | 63 | <script type="text/javascript" src="https://unpkg.com/react-dom@18.2.0/umd/react-dom.production.min.js"></script>
|
64 |
| - <script type="text/javascript" src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@main/dist/en/v6.12.0/build/ol.js"></script> |
65 |
| - <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script> |
66 |
| - <script type="text/javascript" src="https://streetsmart.cyclomedia.com/api/v24.9/StreetSmartApi.js" ></script> |
| 64 | + <script type="text/javascript" src="https://unpkg.com/lodash@4.17.21/lodash.min.js"></script> |
| 65 | + <script src="https://cdn.jsdelivr.net/npm/ol@v10.6.0/dist/ol.js"></script> |
| 66 | + <script type="text/javascript" src="https://streetsmart.cyclomedia.com/api/v25.2/StreetSmartApi.js" ></script> |
67 | 67 | <script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.9.0/proj4.js" integrity="sha512-lO8f7sIViqr9x5VE6Q72PS6f4FoZcuh5W9YzeSyfNRJ9z/qL3bkweiwG6keGzWS0BQzNDqAWXdBhYzFD6KffIw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
|
68 | 68 | </head>
|
69 | 69 |
|
|
121 | 121 | proj4.defs('EPSG:26918', "+proj=utm +zone=18 +ellps=GRS80 +datum=NAD83 +units=m +no_defs");
|
122 | 122 | ol.proj.proj4.register(proj4);
|
123 | 123 | const nad83_zone18_proj = ol.proj.get('EPSG:26918')
|
124 |
| - const xy_nad83 = proj4('EPSG:4326', 'EPSG:26918', xy) |
| 124 | + const xy_nad83 = ol.proj.transform(xy, 'EPSG:4326', 'EPSG:26918') |
125 | 125 |
|
126 | 126 | const view = new ol.View({
|
127 | 127 | center: xy_nad83,
|
|
139 | 139 | source: new ol.source.OSM(),
|
140 | 140 | })
|
141 | 141 | ],
|
142 |
| - controls: ol.control.defaults({attribution: false}).extend([attribution]), |
| 142 | + controls: ol.control.defaults.defaults({attribution: false}).extend([attribution]), |
143 | 143 | target: 'map',
|
144 | 144 | view: view,
|
145 | 145 | });
|
|
239 | 239 |
|
240 | 240 | const vector = new ol.layer.Vector({
|
241 | 241 | source: new ol.source.Vector(),
|
242 |
| - projection: "EPSG:26918", |
243 | 242 | style: new ol.style.Style({
|
244 | 243 | image: new ol.style.Circle({
|
245 | 244 | radius: 3,
|
|
259 | 258 | return new ol.Feature(elem);
|
260 | 259 | }
|
261 | 260 |
|
| 261 | + let addedCoordinates = new Set(); |
| 262 | + |
262 | 263 | function bboxReady() {
|
263 | 264 | var layerSource = vector.getSource();
|
264 |
| - |
265 | 265 | var recordings = wfsClient.recordingList;
|
266 | 266 |
|
267 | 267 | if (recordings.length > 0) {
|
268 |
| - var b = []; |
269 | 268 | for (i = 0; i < recordings.length; i++) {
|
270 | 269 | var rec = recordings[i];
|
271 | 270 | var coord = [rec.lon, rec.lat];
|
272 |
| - var feature = RecordingFeature(coord); |
273 |
| - layerSource.addFeature(feature); |
| 271 | + var coordKey = coord[0] + ',' + coord[1]; |
| 272 | + |
| 273 | + if (!addedCoordinates.has(coordKey)) { |
| 274 | + var feature = RecordingFeature(coord); |
| 275 | + layerSource.addFeature(feature); |
| 276 | + addedCoordinates.add(coordKey); |
| 277 | + } |
274 | 278 | }
|
275 | 279 | }
|
276 | 280 | }
|
|
335 | 339 | }
|
336 | 340 |
|
337 | 341 | var createCanvasContext2D = function (opt_width, opt_height) {
|
338 |
| - var canvas = document.createElement('CANVAS'); |
| 342 | + var canvas = document.createElement('canvas'); |
339 | 343 | if (opt_width) {
|
340 | 344 | canvas.width = opt_width;
|
341 | 345 | }
|
|
0 commit comments