AnsweredAssumed Answered

Move map to an exact lat/long

Question asked by mshah12 on Sep 24, 2018
Latest reply on Sep 25, 2018 by rscheitlin



I have a feature on my application where I provide space for the user to input a latitude and longitude value and the application is supposed to be able to move the map to that location. I have tried the following pieces of code:



$scope.goToLatLong = function(){
      var newLong = dom.byId("longInput").value;
      var newLat = dom.byId("latInput").value;
      console.log("about to change lat, long to:");
      console.log("new long will be: ", dom.byId("longInput").value);
      console.log("new lat will be: ", dom.byId("latInput").value);

      (1) // Point(newLong, newLat), new SpatialReference({wkid: 4326}));
      (2) = view.toMap(newLat, newLong);


The two approaches I tried are (1) and (2). 


With (1), I get the error that .centerAt is not a function and with the (2) approach, the map always moves to the same position no matter what the coordinates that are inputted or even if I switch the line of code to = view.toMap(newLong, newLat); - the code will just move the map halfway down the screen so that top half of the screen is filled with whitespace and the then the top half of the map is showing on screen. 


Can anybody suggest a different approach that they have seen work?


Thank you!