cmeeker

Cannot get point graphic to draw

Discussion created by cmeeker on Oct 11, 2012
Latest reply on Oct 11, 2012 by cmeeker
I am revamping an old example and need help.  The example would allow the user to input a lat lon and would draw a graphic at that point and zoom to it. 

I am trying to re-write it to take a lat lon passed in via the URL and draw a graphic and zoom to it.

**Yes, I know that you can do this on ArcGIS On-Line but I need it to open without the sidebar as this will be used within another application to track locations from a transaction table.** So I just need a simple map, no frills, that shows our property over imagery and adds a point and zooms to it.

The problem I am having is that my point is not drawing.  I am pretty sure that the lat lon is getting passed in correctly as the map is zooming to the right location.

This gets my lat lon from the URL:
                                var url = window.location;    var find = getLatLongFromURL(document.location.href);
    if (!!find)
    {
     var param = find.split(" ");
     var lon = parseFloat(param[0]);
     var lat = parseFloat(param[1]);
     //alert("lat = "+ lat +", lon = " + lon);
    }
     addPointToMap(lon,lat);

and the 2 pertinent functions are:

   function getLatLongFromURL(url)
   {
    var urlObject = esri.urlToObject(url);
    if (urlObject.query && urlObject.query.find)
    {
     return urlObject.query.find;
    }
   }  //end getLatLongFromURL


   function addPointToMap(lon,lat)
   {
    var point = new esri.geometry.Point(lon, lat, pfcMap.spatialReference);
    var symbol = new esri.symbol.SimpleMarkerSymbol().setColor(new dojo.Color([0, 255, 0]));
    symbol.setSize(8);
    var graphic = new esri.Graphic(point, symbol);


    xMin = lon - 0.015;
    yMin = lat - 0.015;
    xMax = lon + 0.015;
    yMax = lat + 0.015;


      var newExtent = new esri.geometry.Extent();
      newExtent.xmin = xMin;
      newExtent.ymin = yMin;
      newExtent.xmax = xMax;
      newExtent.ymax = yMax;
      newExtent.spatialReference = new esri.SpatialReference({ wkid: 102100});


      pfcMap.setExtent(newExtent);
      pfcMap.graphics.add(graphic);


     }  //end addPointToMap




Any help here would be greatly appreciated.

Outcomes