1

I have web based GIS application with multiple layers. Layers gets rendered as image from GeoServer.

Now upon clicking anywhere on the map data of overlapping layers (including line and points) shows up, However after 1-2 minutes upon clicking on map only data of overlapping Polygons is returned and not of lines and points.

If I refresh the web page then again data of lines and points show up on click.

System behaves irregular in returning data for point and lines ,I couldn't understand why ! Please suggest.

Below is my code to get the data on click :

 map.on('singleclick', function (evt) {

    var isAccordion = !!$("#popup-content").data("ui-accordion");
    if (isAccordion) {
        $("#popup-content").accordion("destroy");
    }
    var viewResolution = (view.getResolution());
    var url = multipleSrc.getGetFeatureInfoUrl(
      evt.coordinate, viewResolution, 'EPSG:3857',
      { 'INFO_FORMAT': 'application/json', 'FEATURE_COUNT': 50 }); //text/html

    if (url) {
        var parser = new ol.format.GeoJSON();
        var lookup = {};
        $.ajax({
            url: url,
            dataType: 'json',
            method: 'GET',
            success: function (response) {

                var result = parser.readFeatures(response);
                //if ((result.length > 0) && (wmsLayer.getVisible() == true)) {
                if (result.length > 0) {

                    var coord = evt.coordinate;
                    var content = "";
                    //content = "<div class='row'>";
                    for (var i = 0; i < result.length; i++) {
                        var Feature = result[i];
                        //content = content + "<div class='col-md-3'>";
                        // content = content + "<div class=\"accordion_element\">";
                        content = content + "<h3>" + Feature.getId() + " </h3>";
                        content = content + "<div class=\"accordion_content\">";
                        content = content + '<p>';                            
                        content = content + visitResultProperties(Feature.getProperties(), 1, "");

                        content = content + '</p>';
                        content = content + "</div>"; // According tab div
                        // content = content + "</div>";
                    }

                    content_element.innerHTML = content;
                    $("#popup-content").accordion({ collapsible: true });

                    overlay.setPosition(coord);

                }
            },
            error: function (jqXHR, exception) {
                if (jqXHR.status === 0) {
                    alert('Not connect.\n Verify Network.');
                } else if (jqXHR.status == 404) {
                    alert('Requested page not found. [404]');
                } else if (jqXHR.status == 500) {
                    alert('Internal Server Error [500].');
                } else if (exception === 'parsererror') {
                    alert('Requested JSON parse failed.');
                } else if (exception === 'timeout') {
                    alert('Time out error.');
                } else if (exception === 'abort') {
                    alert('Ajax request aborted.');
                } else {
                    alert('Uncaught Error.\n' + jqXHR.responseText);
                }
            }
        });
    }
});
  • what is returned by the server in each case? – Ian Turton Sep 9 at 13:09
  • GetFeatureInfo url return geoJSON data with the feature information ,which I render and display as a pop up. right after rendering the page it returns data for the point and line as well when I click around them but it behaves randomly and after some time it just returns data for the overlapping polygons. – user684805 Sep 10 at 9:29
  • please add the actual returns - and any other information from the debug console and geoserver log file – Ian Turton Sep 10 at 9:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.