Tax Parcel Viewer - how to search from more than 1 service layer ?

2676
2
05-21-2015 07:11 AM
helenchu
Occasional Contributor II

Hi,

I need to customize the tax parcel viewer to search from 2 different layers.  If nothing found in 1st layer continue to search in 2nd layer.

Could you please help me to accomplish this task ?

Thank you,

Helen

0 Kudos
2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Helen,

Not sure if this is a viable solution, but if you just need the search capability, you could use the Finder App.  This is a configurable web application within ArcGIS Online that you can configure to search multiple layers.

helenchu
Occasional Contributor II

Thanks Jake.  I changed the way of searching now.  In stead of multiple layers I can combine them into 1 point service layer.  However, I still have trouble making the parcel viewer template to work with point service layer.  Could you please help me out ?  JavaScript &  are very new to me. 

I've successfully found the feature intersect with mouse click with the chunk of codes in bold.  The next step is to get the point highlighted, zoomed to and the popup window.

I've tried to do something with the italic bold  but I'm getting nowhere. 

Your help is very much appreciated.

//Query parcel for parcel information

function QueryParcel(layer, parcelId, mapPoint, objectId) {

    if (layer.ParcelQuery) {

        var queryTask = new esri.tasks.QueryTask(layer.ServiceURL);

        var query = new esri.tasks.Query();

        query.outSpatialReference = map.spatialReference;

    query.returnGeometry = false;  //?????

//        query.returnGeometry = true;

      query.outFields = [layer.OutFields];

     if (mapPoint) {

     var centerPoint = new esri.geometry.Point

                (mapPoint.x, mapPoint.y, mapPoint.spatialReference);

     var mapWidth = map.extent.getWidth();

            //Divide width in map units by width in pixels

            var pixelWidth = mapWidth / map.width;

            //Calculate a pixel envelope width

            var tolerance = 50 * pixelWidth;

            var queryExtent = new esri.geometry.Extent

                (1, 1, tolerance, tolerance, mapPoint.spatialReference);

            query.geometry = queryExtent.centerAt(centerPoint);

  

        }

        else {

            var relationshipId;

            parcelAttributeID.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g, function (match, key) {

                relationshipId = key;

            });

            query.where = relationshipId + " in ('" + parcelId + "')";

        }

        query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS;

        ShowProgressIndicator();

        queryTask.execute(query, function (featureSet) {

            if (featureSet.features.length == 0) {

                alert(messages.getElementsByTagName("unableToLocateParcel")[0].childNodes[0].nodeValue);

                HideProgressIndicator();

                return;

            }

            var query1 = new esri.tasks.Query();

            query1.outSpatialReference = map.spatialReference;

            query1.where = dojo.string.substitute(layer.LocateParcelQuery, [dojo.string.substitute(parcelAttributeID, featureSet.features[0].attributes)]);

            query1.returnGeometry = true;

            query1.outFields = ["*"];

            queryTask.execute(query1, function (results) {

                if (results.features.length == 0) {

                    HideProgressIndicator();

                    RemoveScrollBar(dojo.byId("divAddressScrollContainer"));

                    RemoveChildren(dojo.byId("tblAddressResults"));

                    alert(messages.getElementsByTagName("unableToLocateParcel")[0].childNodes[0].nodeValue);

                    return;

                }

               if (!mapPoint) {

                    var polygon = results.features[0].geometry;

                    // var mapPoint = polygon.getExtent().getCenter(); 

                    switch (polygon.type) {

                        case "point":

                            // if the graphic is a point

                            var mapPoint = polygon.geometry;

                            break;

                        case "extent":

                            // if the graphic is an extent

                            var mapPoint = graphic.getCenter();

                        default:

                            // if the graphic is a line or polygon, which for a parcel this will probably

                            // be the case.

                            var mapPoint = polygon.getExtent().getCenter();

                            if (!polygon.contains(mapPoint)) {

                                mapPoint = polygon.getPoint(0, 0);

                            }

                    }

                }

                if (!isMobileDevice) {

                    if (featureSet.features.length == 1) {

                        dojo.byId("tdList").style.display = "none";

                        AddParcelToMap(results.features[0], mapPoint);

                        PopulateParcelInformation(mapPoint, results.features[0], results.features.length, results.features[0].geometry);

                    }

                    else {

                        AddParcelToMap(results.features[0], mapPoint);

                        ShowParcelList(mapPoint, featureSet.features, results.features[0].geometry, queryTask, layer.LocateParcelQuery);

                        dojo.byId("tdList").onclick = function () {

                            ShowParcelList(mapPoint, featureSet.features, results.features[0].geometry, queryTask, layer.LocateParcelQuery);

                        }

                    }

                }

                else {

                    if (isMobileDevice) {

                        HideProgressIndicator();

                        map.infoWindow.setTitle("");

                        map.infoWindow.setContent("");

                        setTimeout(function () {

                            var screenPoint;

                            selectedGraphic = mapPoint;

                            screenPoint = map.toScreen(mapPoint);

                            screenPoint.y = map.height - screenPoint.y;

                            map.infoWindow.resize(225, 65);  // no need to change 2/20/15

                            map.infoWindow.show(screenPoint);

                            if (featureSet.features.length == 1) {

                                for (var i in results.features[0].attributes) {

                                    if (results.features[0].attributes.hasOwnProperty(i)) {

                                        if (!results.features[0].attributes) {

                                            results.features[0].attributes = showNullValueAs;

                                        }

                                    }

                                }

                                map.infoWindow.setTitle(dojo.string.substitute(infoWindowHeader, results.features[0].attributes).trimString(20));

                                map.infoWindow.setContent(dojo.string.substitute(infoWindowContent, results.features[0].attributes));

                            }

                            else {

                                map.infoWindow.setTitle(dojo.string.substitute(featureSet.features.length + " Features found"));

                            }

                            AddParcelToMap(results.features[0], mapPoint);

                            dojo.connect(map.infoWindow.imgDetailsInstance(), "onclick", function () {

                                if (featureSet.features.length == 1) {

                                    ShowProgressIndicator();

                                    PopulateParcelInformation(mapPoint, results.features[0], results.features.length, results.features[0].geometry);

                                }

                                else {

                                    ShowParcelList(mapPoint, featureSet.features, results.features[0].geometry, queryTask, layer.LocateParcelQuery);

                                    dojo.byId("tdList").onclick = function () {

                                        ShowParcelList(mapPoint, featureSet.features, results.features[0].geometry, queryTask, layer.LocateParcelQuery);

                                    }

                                }

                            });

                        });

                    }

                }

            });

0 Kudos