enter address but zoom to polling place

3248
18
12-10-2010 11:11 AM
by Anonymous User
Not applicable
Original User: alnesbit

Hello everyone,

I currently have my flex map from the viewer 2.1 set up to get to a polling place in a 2 step process. First the user enters their address in my locate widget. It zooms to their address. On the map is the name of their precinct (labels on the precinct polygon). Then in the search box they enter their precinct number and then they click on the polling location that shows up in the search results and it zooms to the polling place point.

Is there any possible way to make this one step? Where the user enters their address and it automatically goes to the polling location?

I'm having trouble thinking of how this would work. Appreciate any help,
0 Kudos
18 Replies
RobertScheitlin__GISP
MVP Emeritus
Andrea,

    locate widget returns an XY for the address use a mappoint created from that XY and query the polling locations layer using esriSpatialRelIntersects and the mappoint as the geometry of the query. When the polygon comes back for the polling location use that polygon as the next queries geometry searching for the polling location point layer that esriSpatialRelContains.
0 Kudos
by Anonymous User
Not applicable
Original User: alnesbit

Ok, let me see if I follow you. This wouldn't depend on the polling place points falling within the correct precinct polygon, would it? Because I have polling places outside of their correct precinct, if that makes sense. I also have multiple precincts going to one polling place. But I guess it's sort of a couple of spatial joins?

Thanks,
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andrea,

   Well do the precinct have an attribute that has the proper polling location name then? If so then just use that to do a non spatial search for the polling location name on the polling locations layer.
0 Kudos
by Anonymous User
Not applicable
Original User: alnesbit

Robert and everyone else,

Ok, I have started to look more at the code side of the flex viewer. I also listened to all of the training videos I could find, including 2 from the 2010 Developer Summit meeting in March. I need to make my own widget so I figured I would need to start with the LocateWidget and change it.

I have learned a lot but I'm afraid I'm still a long way from figuring out how to code this.
I have learned that the FindTask is a non spatial search, the QueryTask is done on one feature in a service and is a spatial query using geometry, I will need to use binding {}, returnGeometry="false" is used to not show the results of a query, chaining is what I will need to do to use the results of one for the next query. I was looking at the "RouteDirections.mxml" sample because it takes 2 addresses, sends them to the geocoder, gets the points back and then sends the route. I need to do part of that so I thought I could learn something and use that code but this is still a bit over my head.

The LocateWidget confuses me. I was comparing it to the LocatorTask.mxml sample and in that sample you can give the textboxes default values, like text="redlands" but I can't find where I could do that in the LocateWidget because it seems to be set up differently.

I'm pretty clear on the steps, I'm just not clear on how to code it! ha. I need to get the xy location from the address that the user selects in the LocateWidget. I need to turn that xy location into a mappoint. Using that mappoint I need to do a QueryTask with the precincts poly layer using esriSpatialRelIntersects. I will then get the name of the polling location from a field within the precinct poly feature class. Then I need to do a FindTask to query and select the same polling place name in the polling place point feature class and then I can zoom to the selected point.

I know there is another sample out there for the last query, but I'm stuck at the beginning. Does anyone have any hints or other places I could go to figure this out?

Will be cool when it works. Thanks in advance,
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andrea,

  Take a look at this example. It is basically what you are wanting. What it does is uses my locator to get the XY of an address and places a graphic on the map, then queries the districts layer and gets the polygon district that intersects it and then uses that polygon to find the schools points that are inside it and attaches attributes from the schools results to the original graphic of the address.

Hope it Helps.
0 Kudos
by Anonymous User
Not applicable
Original User: alnesbit

Robert and everyone,

I have tried to take your code and change it to do my tasks. I'm happy to say that I finally understand all of your code. But I have not been too successful changing it for my project.

I can't even get it to geocode my address right now. Do you see anything wrong with my code? Do you see anything else wrong, right away?
The locator works in ArcMap. It's a 9.3.1 composite locator because I can't get Arc10 to create a composite locator - keeps giving me error message.

Appreciate any help. Thank you!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andrea,

You were real close. I comment my changes.
0 Kudos
by Anonymous User
Not applicable
Original User: alnesbit

Robert,

Thank you so much! I'm getting closer every step.

Now all I have to do is change it to zoom to the polling point, not the address point. I'm afraid I have made a real mess of this code. I am attaching below. I sort of understand the concept. I need to use the query2 geometry and use that to zoom to. But I'm trying to use the sample "QueryTaskOnMap.mxml" and mix it with the code I already have. In most spots I'm guessing as to how it might work. And of course now I'm getting the warning: Data binding will not be able to detect assignments to "queryTask2".

Do you have any further guidance or ideas of where I could look to get this to work? I'm sorry to keep asking. I sort of dove into the deep end of the flex pool instead of wading in from the shallow side!
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andrea,

OK, here is the app reworked. It had my head hurting until I looked at your data closely.
0 Kudos