Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to make my way through some ArcGIS server Javascript API tutorials. My current issue is that when I try to display an Esri.Map, all I see is the "powered by esri" logo in the bottom right. My init is below as is my mapDiv.

function init () {

    map = new esri.Map("mapDiv",{
      basemap: "hybrid",
      center: [-80.94, 33.646],
      zoom: 8
    });

    //Create your query
    var queryTask = new esri.tasks.QueryTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSFields/MapServer/0");
    //set the onComplete event handler, in this case, when the query is complete, call initLineID,
    //production code would handle handle the error callback as well
    dojo.connect(queryTask, "onComplete", initLineID);

    //build and execute your query
    var query = new esri.tasks.Query();
    query.outFields = ["field_name"];
    query.text = "all";
    query.returnGeometry = true;
    queryTask.execute(query);

}


<div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>

Any reason why this would not be working?

share|improve this question

1 Answer 1

You are not adding a layer to the map which is why you only see the logo and a white map.

Try for example adding the world street map:

    var map = new esri.Map("mapDiv");
    var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
    map.addLayer(dynamicMapServiceLayer);

Here is a simple map js fiddle that you can play with

http://jsfiddle.net/dave_wilton/mSQHp/

share|improve this answer
    
Thank you! How can I maintain the original code I had to start at a predefined lat/lon location and zoom level? I tried leaving that in the call to new esri.Map but it seems to be ignored. –  user1100652 Jan 21 '13 at 22:01
    
After looking at this a little more, looks like I should have been more specific in the question. How can I accomplish this by using a basemap rather than a full layer? Here's an esri demo that accomplishes more or less what I'm after: esri.com/getting-started/developers/get-started/javascript –  user1100652 Jan 21 '13 at 22:09
    
Appologies, you need to be clear on which version of the API you are trying to use too. Version 3.3 was just released this week and I haven't looked at it. Seems there are some changes to the map object. Fiddle updated to use version 3.3 and set the extent. jsfiddle.net/dave_wilton/mSQHp –  David Wilton Jan 22 '13 at 7:37
    
So in answer to your original question why does the basemap not show, perhaps it is that you are not using the latest version of the API? –  David Wilton Jan 22 '13 at 7:46

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.