marylandgis

How to fetch the lat/long values from a table in an HTML page

Discussion created by marylandgis on Sep 12, 2011
Latest reply on Sep 12, 2011 by Steaks
I am a Javascript novice.  I appreciate your help.

I would like to fetch the lat/long values from a table in an HTML page, so that a  map on the same web page is centered and zoomed to that location.

Here is a simple center-extent builder that I use to configure the initialExtent variable :

  var myZoom = 20000;
  var myLat = 4518898;
  var myLong = -13618751;
  var myXMin = myLong - myZoom;
  var myXMax = myLong + myZoom;
  var myYMin = myLat - myZoom;
  var myYMax = myLat + myZoom;

It configures the initial extent of the map like this:

       var initialExtent = new esri.geometry.Extent({"xmin":myXMin,"ymin":myYMin,"xmax":myXMax,"ymax":myYMax,"spatialReference":{"wkid":102100}});

I would like to get the values of myLat and myLong using something like this

  var myLat = document.getElementById("siteLat");
  var myLong = document.getElementById("siteLong");

from a table that is hard-coded into the web page like this:

<body>
<table><tr>
<td>Adams Landing</td>
<td id="siteLat">4518898</td>
<td id="siteLong">-13618751</td>
<td>Sailing Vessel Landing</td>
<td>1875</td>
<td>1950</td>
</tr></table>
</body>

But myLat and myLong vars evaluate to null.  Is there something about the scope of the vars, or the init function that builds the map, that I need to consider to make this work?

Thanks,

Outcomes