Problems with map.setextent()

Discussion created by damccutcheon on Apr 26, 2011
Latest reply on May 4, 2011 by tol82
I am building a website that will pull multiple lat/long points from a database and plot them on a map.  The problem I'm having is when I go to set the extent to show only the points plotted, the extent only shows the first point.

I'm using "map.setExtent(NewExtent, true)", and when I step through the code the line is hit for every point, but only the first call seems to matter.

I've included a code snippet below.  Also, this is my first ESRI project so if you see me doing something dumb, let me know and I'll correct it.

Thanks for the help.

Code below:
function init() {
            map = new esri.Map("CallMap");
            var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer", {opacity:0});
            map.setExtent(esri.geometry.geographicToWebMercator(new esri.geometry.Extent((-75.646399), (40.824849), (-74.883529), (41.248469), new esri.SpatialReference({ wkid: 2271 }))));

            dojo.connect(map, 'onLoad', function () {
                var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,255,0.65]), 2), new dojo.Color([0,0,255,0.35]));
  addToMap(map, 41.092236000, -75.323746000, 'images/pnt.png', '149');
  addToMap(map, 40.970196000, -75.277355000, 'images/pnt2.png', '19');



        function addToMap(map, lat, lon, pic, dis) {
            var myExtent = new esri.geometry.Extent((lon - 0.003), (lat - 0.003), (lon + 0.003), (lat + 0.003), new esri.SpatialReference({ wkid: 2271 }));
            myExtent = esri.geometry.geographicToWebMercator(myExtent);
            var point = new esri.geometry.Point(lon, lat, new esri.SpatialReference({ wkid: 2271 }));
            var point_wm = esri.geometry.geographicToWebMercator(point);
            var picsymbol = esri.symbol.PictureMarkerSymbol(pic, 33, 40);
            var attr = { "XCoord": lon, "YCoord": lat, "Desc": dis };
            var infoTemplate1 = new esri.InfoTemplate("Latitude: ${YCoord} <br/>Longitude: ${XCoord}", "POI: <br/>${Desc}");

            polygonGraphic = new esri.Graphic(point_wm, picsymbol, attr, infoTemplate1);

            map.setExtent(myExtent.expand(1.25), true);