Map object creation

660
2
08-30-2013 07:23 AM
vinayb
by
New Contributor III
HI All,

  I am confused over map object creation ,pls guide me.I add below code i got the map even if i dint refer any url

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>Feature Layer Only Map</title>
    <link rel="stylesheet" href="http://js.arcgis.com/3.6/js/esri/css/esri.css">
    <style>
      html, body, #map {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
    <script src="http://js.arcgis.com/3.6/"></script>
    <script>
 dojo.require("esri.symbols.SimpleFillSymbol");
 dojo.require("esri.symbols.SimpleLineSymbol");
 dojo.require("dojo/_base/Color");
 dojo.require("esri/graphic");
 var map;
 var infoTemplate;
      require([
        "dojo/dom-construct", 
        "esri/map", 
        "esri/layers/FeatureLayer",
        "esri/geometry/Extent",
        "esri/InfoTemplate",
  "esri/symbols/SimpleFillSymbol",
  "esri/symbols/SimpleLineSymbol", 
  "dojo/_base/Color", 
  "esri/graphic",
        "dojo/domReady!"
      ], function(
          domConstruct,
          Map,
          FeatureLayer,
          Extent,
          InfoTemplate,
    SimpleFillSymbol,
    SimpleLineSymbol,
    Color,
    graphic
        ) {
          var bounds = new Extent({
            "xmin":-16045622,
            "ymin":-811556,
            "xmax":7297718,
            "ymax":11142818,
            "spatialReference":{"wkid":102100}
          });
           map = new esri.Map("map", { 
          basemap: "streets", 
          zoom: 2 
        }); 
          
        }
      );
    </script>
  </head>
  <body>
    <div id="map"></div>
  </body>
</html>


but then i added below lines

var url = "http://10.32.9.106:6080/arcgis/rest/services/Administrative_Maps/World_Countries_v1/MapServer/0";

         

          var fl = new FeatureLayer(url, {
            id: "world-regions"
            //infoTemplate: template
          });
          
      
     map.addLayer(fl);


the map loaded then color of map changed and browser can anybody explain whats going on , how can i an initialize map without url and if i want map to be loaded from  my rest service http://10.32.9.106:6080/arcgis/rest/services/Administrative_Maps/World_Countries_v1/MapServer/0  what is  the right way.
0 Kudos
2 Replies
JasonZou
Occasional Contributor III
I think your code is working. Your map first loads the world street map service as the basemap, then you load the feature layer which sits on top of the basemap. I guess the feature layer is a polygon layer, and colored by countries so that the feature layer covers the basemap. Does that make sense?
0 Kudos
vinayb
by
New Contributor III
IT does but this makes the browser to hang when i apply feature layer , how can i retain my basic map but still applying Feature layer.I dont want polygon it is making things slow.
0 Kudos