Select to view content in your preferred language

Map graphics problems

1071
1
11-18-2010 10:12 PM
RicardasVaitkus1
New Contributor
Hi.

I am want to create a form for route printing. With maps for each route direction.
I have wrote a functio to create a simple map for html node with layers I need and extent, but I have one problem - map graphics is not displayed on map, despite map.graphics object has all graphic it needs (with geometry and symbols). Can someone help me? Here is my code:

function createMap(srcNodeRef, pExtent, pLayers){
    // CREATE MAP
    var map = new esri.Map(srcNodeRef, {
        extent: pExtent,
  logo : false,
        slider: false
    });
 dojo.connect(map, "onLoad", addGraphicsPrint);
 try {
  for (var i=0; i<pLayers.length - 1; i++) {
   map.addLayer(pLayers);
  };
 } catch (e) {
  alert(e.message);
 }
 map.graphics.refresh();
 return map;
}

function addGraphicsPrint(map) {
    try {
  for(var i = 0, il = route.features.length; i<il; i++) {
   var feat = route.features;
   feat.setSymbol(routeSymbol);
   map.graphics.add(feat);
  }
    } 
    catch (e) {
     alert(e.message);
    }
} 
0 Kudos
1 Reply
HemingZhu
Frequent Contributor
Hi.

I am want to create a form for route printing. With maps for each route direction.
I have wrote a functio to create a simple map for html node with layers I need and extent, but I have one problem - map graphics is not displayed on map, despite map.graphics object has all graphic it needs (with geometry and symbols). Can someone help me? Here is my code:

function createMap(srcNodeRef, pExtent, pLayers){
    // CREATE MAP
    var map = new esri.Map(srcNodeRef, {
        extent: pExtent,
  logo : false,
        slider: false
    });
 dojo.connect(map, "onLoad", addGraphicsPrint);
 try {
  for (var i=0; i<pLayers.length - 1; i++) {
   map.addLayer(pLayers);
  };
 } catch (e) {
  alert(e.message);
 }
 map.graphics.refresh();
 return map;
}

function addGraphicsPrint(map) {
    try {
  for(var i = 0, il = route.features.length; i<il; i++) {
   var feat = route.features;
   feat.setSymbol(routeSymbol);
   map.graphics.add(feat);
  }
    } 
    catch (e) {
     alert(e.message);
    }
} 


Instead of using default graphic layer: map.graphics, explicitly create a graphic layer and add graphic to it. Example: var gLayer = new esri.layers.GraphicsLayer(); map.addLayer(gLayer); gLayer.add(graphic);
0 Kudos