AppStudio Offline Local Locator Zoom QML

1396
4
08-30-2016 04:25 PM
by Anonymous User
Not applicable

I am creating an offline app using AppStudio Desktop and have the higher license level. I was able to utilize the Local Locator sample code and have that working fine. But was hoping for the app to zoom into the location once it finds it (it currently just puts a red plus sign there). Any ideas on how to do this? Maybe in the extent line:

onFindStatusChanged: {
            if (localLocator.findStatus === Enums.FindStatusCompleted) {
                if (localLocator.findResults.length < 1) {
                    showError("No Match Found");
                } else {
                    for (var i = 0; i < localLocator.findResults.length; i++) {
                        var result = localLocator.findResults[i];
                        console.log("Result", i, result.address, result.score, result.location.x, result.location.y, result.extent.toText(), result.spatialReference.toText(), result.toText());
                        var newGraphic = graphicLocation.clone();
                        newGraphic.geometry = result.location;
                        var id = graphicsLayerStops.addGraphic(newGraphic);
                    }
                    mainMap.extent = localLocator.findResults[0].extent;
                }
            } else if (localLocator.findStatus === Enums.FindStatusErrored) {
                showError("Error: " + localLocator.findError.message + "\n\n");

Note, I am not a developer/programmer, just a GIS person who was hoping this would be easy to use! 
I tried using the Feature Finder code I found on github, but can't get it to work offline and was told 
by esri it won't work for offline yet (waiting for Quartz updates). I love the way that code works because
it also provides options for the name while you're typing in the search box. If anyone knows how
to pull that off for offline, that'd be icing!!

Thanks!! 
0 Kudos
4 Replies
nakulmanocha
Esri Regular Contributor
You can do 
map.zoomTo(geometry)

If you don't like the zoom level then alternatively you can 
map.panTo(geometry)
map.zoomToResolution( specify the resolution )
0 Kudos
by Anonymous User
Not applicable

Nakul,

Thanks so much for the response (and quick!). Excuse my ignorance, but where do I put this in the code? If it helps, I can post all the code for the local locator. 

Thanks again!

Vanessa

0 Kudos
nakulmanocha
Esri Regular Contributor

You can do it right after you get the location back. 

newGraphic.geometry = result.location;
map.zoomTo(newGraphic.geometry)

and you don't need this line I believe. But you can give it a try.
 mainMap.extent = localLocator.findResults[0].extent;

0 Kudos
by Anonymous User
Not applicable

Thanks for your help Nakul, but I still have not been able to get any version of this to work. Any other suggestions? Thank you for your consideration!!

0 Kudos