1

I am getting this error:

SELECT * FROM parcels_sa WHERE parcel_id ILIKE '%001089800%'
mapscript.js?1437514849:273 
Uncaught TypeError: layer.setQuery is not a function(anonymous function) 
@ mapscript.js?1437514849:273x.event.dispatch @ jquery.min.js:5x.event.add.y.handle @ jquery.min.js:5
cartodb.js:5 GET http://dchadney.cartodb.com/api/v2/sql?q=SELECT%20ST_XMin(ST_Extent(the_geo…arcels_sa%20WHERE%20parcel_id%20ILIKE%20%27%25001089800%25%27)%20as%20subq

net::ERR_EMPTY_RESPONSE

enter image description here

function parcelSearch(layer) {
    var sql = new cartodb.SQL({ user: 'username' });
    var $options = $('#searchParcel');
    $options.click(function(e) {
        var streetNam = document.getElementById('parcelid').value;
        if(streetNam === "") {
            alert("Please enter the parcel ID");
        } else {
            query = "SELECT * FROM parcels_sa WHERE parcel_id ILIKE '%" + streetNam + "%'";
            console.log(query);
            layer.getSubLayer(0).show();

            sql.getBounds(query).done(function(bounds) {
                latlon = bounds[0];
               // console.log(latlon);
                //alert(latlon);
                $('.latlongit').val(latlon);
                map.fitBounds(bounds);
            });
        }

        // change the query in the layer to update the map
        layer.setQuery(query);

    });       

    var $clear = $('#clear');
    $clear.click(function(e) {
            $('#parcelid').val('');
            query = "SELECT * parcels_sa";
            console.log(query);
            layer.getSubLayer(0).hide();
            sql.getBounds(query).done(function(bounds) {
            latlon = bounds[0];
            map.fitBounds(bounds);
            });
        // change the query in the layer to update the basemap
        layer.setQuery(query);
    });
}
1
  • There is an edit button beneath your question that allows you to revise it with the error and format it. Comments are temporary, and only there to help you improve your question. – PolyGeo Jul 21 '15 at 23:05
1

You're probably needing layer.setSQL(query). As the error says, setQuery is not a function in CartoDB.js.

Documentation for setSQL is here and here.

1
  • 1
    Okay setQuery is a function in an older version of CartoDB, so that was my issue. Thanks! – dchadney Jul 23 '15 at 15:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.