I had created a application using ArcGIS API for JS to geolocate features in the feature layer that is added to basemap. I have an external Javascript and css file that are referenced (called) to html file. When I tried to run the html from web server it is sending an error message (script.js:1 Uncaught SyntaxError: Unexpected token <) for first line of JS file.

I re-checked my scripts couple of times, but I couldn't find any mistake in it. Is there anything wrong with Javascript syntax? Please check the below scripts:


<script src="https://js.arcgis.com/3.15/"></script>

var map;


function(Map, FeatureLayer, Search) {       
    map = new Map("mapDiv", {       
        basemap: "streets",        
        center: [-56.049, 38.485],
        zoom: 3,

    var Search = new Search({
        allPlaceHolder: "Find by address",    
        autoNavigate: false,
        autoSelect: false,
        enableHighlight: true,
        enableInfoWindow: true,
        enableSearchingAll: true,
        showInfoWindowOnSelect: true,
   },"Address"); });



    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>Geolocating parcels</title>
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.15/esri/css/esri.css">
    <link rel="stylesheet" type="text/css" href="https://js.arcgis.com/3.15/dijit/themes/claro/claro.css">
    <script src="https://js.arcgis.com/3.15/"></script>
    <link rel ="stylesheet" href ="styles.css">

  <div id = "mapDiv" style="position: relative; width:50px; height:50px; border:1px solid #000;"></div>
  <div id = "Address">  </div>  

  <script src="script.js" type ="text/javascript" ></script>
  <script src="https://js.arcgis.com/3.15/"></script>

2 Answers 2

  1. You're calling <script src="https://js.arcgis.com/3.15/"></script> multiple times in your HTML file.
  2. You can't use <script> HTML tags inside your .js file.

I believe it is a problem with your call to the script, i think if you remove the duplicates you will fix your problem.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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