Zoom to feature

1199
9
02-07-2012 08:16 PM
deleted-user-K_IRAXrpGKsG
Deactivated User
Hello,

Does anyone know if the find task has the capability to zoom to a specific feature within a feature class?

For example, when someone enters "Hyland" for a building name, is there a way to automatically pan or zoom
to that specific building?

I've been able to highlight a building using the search, but have been unable to pan to it. Any ideas?

Thanks!
9 Replies
derekswingley1
Deactivated User
The find task returns data. It's up to you what you do with it.

Things like map navigation (zoom or pan) are easy to do with the API. Take a look at centerAt, centerAndZoom and maybe setLevel.
0 Kudos
CesarRevilla
Regular Contributor
Hello,

1. first in Findparameters: returnGeometry = true
2. FoundGraphic = RETURNEDOBJECT.features;
3. map.centerAndZoom(FoudnGraphic.geometry.getCenter(), zoomlevel);

(zoomlevel = 0,1,2,3, etc)

Regards,
orzundher
0 Kudos
CesarRevilla
Regular Contributor
But I have a new Question:

ist posible to apply .GetDojoShape() in this findTask Data? (or have access to his Style or Outline).

Thank You!
orzundher
0 Kudos
derekswingley1
Deactivated User

ist posible to apply .GetDojoShape() in this findTask Data? (or have access to his Style or Outline).

It's probably best to start a new thread...

But to no, .getDojoShape() is not applicable to findTask results do not have symbology. It's up to your app to create a graphic from the findResult using the returned geometry and a symbol you create.
0 Kudos
CesarRevilla
Regular Contributor
Hi,

ok, now I think, I need to use the standart highlight method 🙂
I went to make a hightlight without create a new object (its not possible without the previous simbology).

Thanks!
orzundher
0 Kudos
deleted-user-K_IRAXrpGKsG
Deactivated User
The find task returns data. It's up to you what you do with it.

Things like map navigation (zoom or pan) are easy to do with the API. Take a look at centerAt, centerAndZoom and maybe setLevel.


Thanks for the reply but that still doesn't answer the question of how I can automatically pan to a specific building using the find task.
0 Kudos
CesarRevilla
Regular Contributor
Hi, you need to create a function, you can use this function in your "execute".

Use this "execute" statement  after the "map, 'onLoad'" event.
0 Kudos
derekswingley1
Deactivated User
Thanks for the reply but that still doesn't answer the question of how I can automatically pan to a specific building using the find task.

Check out this fiddle:  http://jsfiddle.net/e7nPx/

The find task does not have anything to do with map navigation. To pan and/or zoom to a location or feature, use the methods available on the map class. In addition to the methods I mentioned previously, you could also use setExtent() if you want to zoom to a specific polygon. This is what the code shown in the fiddle linked above does.
0 Kudos
DanPajak
Regular Contributor
Have you looked at Show Find Task results in DataGrid? When you click on the DataGrid result it will zoom to the returned feature.
0 Kudos