-1

I have SQL query in my code and after it responses I want to go to query result extent. What I have now is that after respond it goes somewhere in Atlantic ocean. Here is my code:

    //rukis Seqmna
     var map = new Map({
basemap: "topo",
layers: [resultsLayer]
        });
var view = new MapView({
container: "viewDiv", 
map: map, 
extent: { // Extent Chemi rukistvis()
        xmin: 5278000,
        ymin: 5147000,
        xmax: 4377000,
        ymax: 5247784,
        spatialReference: 102100
      }
    });



  //saZiebo panelis damateba (Widget)
    view.ui.add("infoDiv", "top-right");




   on(queryZebna, "click", function() {
        queryMagistraluri()
        .then(displayResults);



    });

    function queryMagistraluri() {
      var query = HWLayer.createQuery();
     //query.returnGeometry = true;
     //query.outFields = ["*"];
     let searchTerm = document.getElementById('searchInput').value;
     query.where = "სარწყავი_სისტემა LIKE N'%"+ searchTerm +"%'"; 
     query.outSpatialReference = view.spatialReference;
     return HWLayer.queryFeatures(query)

     .then(function(response) {
        view.goTo(response.extent);
      });







    // display the query results in the view

    function displayResults(results) {

      console.log(results);

      resultsLayer.removeAll();
      var features = results.features.map(function(graphica) {
        graphica.symbol = {
          type: "simple-line", // autocasts as new SimpleMarkerSymbol()
          style: "Solid",
          size: "50px",
          color: "#f0f"
        };
        return graphica




      });
      resultsLayer.addMany(features)
2

Your map is using a projected coordinate system that is measured in metres and your database is using a geographic projection which is measured in degrees so when you use the results without reprojecting the coordinates are too small and you end up on Null Island.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.