AnsweredAssumed Answered

Having a problem with goTo

Question asked by rkelso on May 20, 2016
Latest reply on May 24, 2016 by rscheitlin

I'm working on a very simple map just as a learning exercise.  I want it to select, highlight, and zoom to a defined parcel.  It works, except that some of the time I get this error:  "TypeError:  Cannot read property 'wkid' of null".  I get the error when the MapView.goTo() method tries to fire, but the graphics are visible on the map.


I'm a beginner trying to learn, so consider that when checking out the code.  My parcel data is not public so I swapped it out for King County data below, but oddly I can't get the error to occur with this other data.  Any ideas about what's going on?


    ], function(Map, PopupTemplate, MapView, MapImageLayer, GraphicsLayer, SimpleFillSymbol, QueryTask, Query, arrayUtils) {

      var parcelsMapService = MapImageLayer({
        url:  "",
        sublayers: [
            id: 2,
            visible: true

      var resultsLayer = new GraphicsLayer();
      var map = new Map({
        basemap: "topo",
        layers:  [parcelsMapService, resultsLayer]

      var view = new MapView({
        container: "viewDiv",
        map: map,
        zoom: 11,
        center: [-122, 47.5]
      var popupTemplate = PopupTemplate({
        title: "Selected Parcel",
        content: "{PIN}"
      var queryTask = new QueryTask({
        url: ""

      var pinQuery = new Query({
        returnGeometry: true,
        outFields: ["*"],
        outSpatialReference: {"wkid": 4326}
      pinQuery.where = "PIN = '7666204876'";
      function getResults(response) {
        var parcelResults =, function(feature) {
          feature.symbol = new SimpleFillSymbol({
            color: [255, 255, 0, 0.25],
            style: "solid",
            outline: {
              color: [255, 255, 0],
              width: 3
          feature.popupTemplate = popupTemplate;
          return feature;
        return parcelResults;
      function addToLayer(parcelResults) {

      function goToLayer() {