AnsweredAssumed Answered

Access ArcGIS JS API from external JS file?

Question asked by brett1989 on Nov 2, 2016
Latest reply on Nov 3, 2016 by rscheitlin

Hi Guys

 

So I have created my map with the webapp builder and plugged it into a system. When displaying the map I use the index.html file from the map.

 

I load my script like this at the bottom of the index.html file:

 <script type="text/javascript" src="*.js"></script>

 

My script does a basic thing like a zoom using the CentreAndZoom function of the map, but I do however create a point by using legacy code such as: point = new esri.geometry.Point(lng, lat);

 

But it seems I cannot access anything else in the JS api, any ideas why or how to enable my js file to have access to the functions provided by the API?

 

My js file:

 

//map object
var esriMap;

 

function zoomTo(lat, lng, factor) {
    var point;
    point = new esri.geometry.Point(lng, lat);
    esriMap.centerAndZoom(point, factor);
 
}

 

function setZoom(faktor) {
    esriMap.setZoom(faktor);
}

 

What happens so far is that I have dropdowns on my html page and this calls my zoomTo function which zooms to a point on the map. I am trying now to highlight the point with the SimpleMarkerSymbol function but I cannot get any access to it at all, says undefined now this could be that I do not declare it but if my point is declared in this matter and works should a markersymbol not work the same?

 

Looking forward to you're responses.

 

Brett

Outcomes