javascript - OL3 overlay not displaying - appendChild error -
i have ol3 application displays map overlays have found in version 3.20 no longer display.
my console log gives following error:
uncaught typeerror: failed execute 'appendchild' on 'node': parameter 1 not of type 'node'.
below code use; when user enters 2 values , clicks on button, retrieve these values , zoom map coordinates, not display overlays. need alter code in way?
//zoom map on coordinate zoom button click $("#coord-zoom-btn").click(function() { var x = parseint(document.getelementbyid('coord-x').value); var y = parseint(document.getelementbyid('coord-y').value); map.setview(new ol.view({ projection: ol.proj.get('epsg:27700'), resolutions: [28.0, 14.0, 7.0, 3.5, 1.75, 0.875, 0.4375, 0.21875, 0.109375], center: [x, y], resolution: 0.21875 })); if (coordinatemarker && coordinatelabel != null) { map.removeoverlay(coordinatemarker); map.removeoverlay(coordinatelabel); } coordinatemarker = new ol.overlay({ position: [x, y], positioning: 'center-center', element: $('<img src="img/marker/icon_coordinates.png" alt="coordinate marker position">') }), coordinatelabel = new ol.overlay({ position: [x, y], positioning: 'center-center', offset: [0, -20], element: $('<h6>x: ' + x + ' y: ' + y + '</h6>') }) map.addoverlay(coordinatemarker); map.addoverlay(coordinatelabel); });
Comments
Post a Comment