Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

JS:

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

<script>
var map;

require([
    "esri/map",
    "esri/layers/FeatureLayer",
    "esri/dijit/Search",
     "dojo/domReady!",
    ], 

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,
        map:mapDiv,
        showInfoWindowOnSelect: true,
        theme:arcgisSearch,
        zoomScale:1000
   },"Address"); });

</script>

HTML

<html>
  <head>
    <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">
</head>

  <body>
  <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>
  </body>
</html>
share|improve this question
up vote 2 down vote accepted

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

share|improve this answer
    
Thank you! I fixed. – Mukhtar Ahmed Jan 8 at 18:18
  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.
share|improve this answer
    
Thank you. I fixed. – Mukhtar Ahmed Jan 8 at 18:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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