ArcGIS Javascript API layerlist trigger action "zoom-to" using view.goTo() not working

540
4
Jump to solution
07-22-2019 10:49 AM
JennyHuang3
New Contributor III

Hi all,

Seems like this should be an easy operation but for some reason the view.goTo() is not doing anything at all

Thinking this might be a spatial reference issue (?) but not sure how to fix it...(the online sample code worked for me but the zoom imagery layer's wkid is 4326...)

Additional info:

view.spatialReference's wkid is 102100

event.item.layer's wkid is 102190

Any help is appreciated!! Thank you!! - Jenny

const layerlist = new LayerList({
view: view,
container: dom.byId("legend"),
listItemCreatedFunction: function(event){
const item = event.item // ListItem class
if (item.layer.type !== "group"){
item.actionsSections = [[{
title: "Zoom To",
className: "esri-icon-zoom-in-magnifying-glass",
id: "zoom-to"
}....
view.when(function(){
// layer list trigger action:
layerlist.on("trigger-action", function(event){
console.log("triggered event", event.item.layer)
// capture action id:
let id = event.action.id;
if (id === "zoom-to"){
view.goTo(event.item.layer.fullExtent) // not working...
}....
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Jenny,

  You need to project the layer full extent to the maps spatial reference.

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Jenny,

  You need to project the layer full extent to the maps spatial reference.

View solution in original post

0 Kudos
JennyHuang3
New Contributor III

Thanks for the quick reply Rob!

that's what i was thinking...tried below but getting Type Error: g is null....

am i even on the right track?

let transformation = projection.getTransformation(event.item.layer.fullExtent.spatialReference, view.spatialReference)
let projExtent = projection.project(event.item.layer.fullExtent, view.spatialReference, transformation)
view.goTo(projExtent) // not working...
RobertScheitlin__GISP
MVP Esteemed Contributor

Jenny,

   That looks fine. Did you call projection.load() earlier in your code?

JennyHuang3
New Contributor III

no lol it's working now.

thanks Rob. much appreciated

0 Kudos