Uncaught ReferenceError: LAYERS is not defined-Openlayers 4

123 views
Skip to first unread message

Nauwanga Nauwanga

unread,
Jun 30, 2018, 2:31:51 PM6/30/18
to openlay...@googlegroups.com
I am using OpenLayers 4 to building my app. Although I have successfully created an app which only one layers identify as per this tutorial https://openlayers.org/en/latest/examples/getfeatureinfo-image.html

I then edited the code to ideally get attribute information for multiple layers using the following code

 map.on('click', function (evt) {
    var url = LAYERS.getSource().getGetFeatureInfoUrl
        evt.coordinate, viewResolution, viewProjection,
                'INFO_FORMAT': 'text/html',
                'QUERY_LAYERS': 'County:Boundary,County:Regions,County:Constituency,County:Towns'   
            if (url) {
          document.getElementById('info').innerHTML =

                content.innerHTML = '<iframe seamless src="' + url + '"></iframe>';
                }
                });

      map.on('pointermove', function(evt) {
        if (evt.dragging) {
          return;
        }
        var pixel = map.getEventPixel(evt.originalEvent);
        var hit = map.forEachLayerAtPixel(pixel, function() {
          return true;
        });
        map.getTargetElement().style.cursor = hit ? 'pointer' : '';
      });
Then I get the error ReferenceError: LAYERS is not defined

The application is complaining about the ol.js

Can someone please advise on how to go about resolving this error?

Many thanks & regards
Amelia
Reply all
Reply to author
Forward
0 new messages