Below is my code that I need help with. This is what I have drawing my
line.
    var polyOptions = {geodesic:true};var polyline = new GPolyline
([  new GLatLng(36.089444, -80.270278),  new GLatLng(lat,lon)  ],
"#ff0000", 10, 1, polyOptions);  map.addOverlay(polyline);

which works from the fixed point to what is entered in the text box to
map. BUT I am wanting it to draw from the last point enter on the maps
OR to draw a new line from point to point each time a new one is
added.

Can you point me in the right direction. Here is the links to the
page.

https://sauratownfire.com/gps_position_reportsTEST.htm

_________________________________________________________________________
var map = false;
var info;
var markers;
var i = 0;
var timeout = 1;
var lMessage


var baseIcon = new GIcon(G_DEFAULT_ICON);
baseIcon.image = "";
baseIcon.shadow = "";
baseIcon.iconSize = new GSize(16, 16);
baseIcon.shadowSize = new GSize(1, 1);
baseIcon.iconAnchor = new GPoint(8, 16);
baseIcon.infoWindowAnchor = new GPoint(7, 1);

function mapOne() {

//  alert("we have " + markers.length + " markers " + i);

  if ( i < markers.length )
  {
//    alert("adding marker");

    var max = Math.min(i + 20, markers.length);

    while (i < max) {

      var point = new GPoint(parseFloat(markers[i].getAttribute
("lng")),
                             parseFloat(markers[i].getAttribute
("lat")));

      var html = markers[i].getAttribute("txt");
      var icon = markers[i].getAttribute("icon");


      marker = createMarker(point, html, icon);
      map.addOverlay(marker);

//      alert("adding marker");

      i++;
    }
    if (lMessage)
    {
//      lMessage.innerHTML="<p>Loading " + i + " of " + markers.length + "</
p>";
    }
    window.setTimeout(mapOne,timeout);
  }
  if ( i >= markers.length )
  {
//    document.getElementById
('loading').style.visibility='hidden';
  }
}

var _zoomLevels = new Array
(
0.006909370422363281,
0.013818740844726562,
0.027637481689453125,
0.05527496337890625,
0.1105499267578125,
0.221099853515625,
0.44219970703125,
0.8843994140625,
1.768798828125,
3.53759765625,
7.0751953125,
14.150390625,
28.30078125,
56.6015625,
113.203125,
226.40625,
452.8125,
905.625
);

function calculateZoomLevel(spanLng, spanLat)
{
    var level = _zoomLevels.length-1;
    var found = false;
    var index = 0;

    // Get largest value
    var compareTo = spanLng;
    if (spanLat>spanLng) compareTo = spanLat;

    while (!found && index<_zoomLevels.length)
    {
        if (_zoomLevels[index]>compareTo)
        {
            level = index;
            found = true;
        }
        index++;
    }

    return level

}

function loadCoords(url, type)
{
    if (url == "")
        return;

    i = 0;
    var request = GXmlHttp.create();
    request.open("GET", 'gmapxml.php?type=' + type + '&url=' + escape
(url), true);

//alert("getting gmapxml.php?url=" + escape(url));

request.onreadystatechange = function() {
  if (request.readyState == 4) {
    var xmlDoc = request.responseXML;

    var centers = xmlDoc.documentElement.getElementsByTagName
("center");
//    alert("centers " + centers[0].getAttribute("lng") + ", " +
centers[0].getAttribute("lat"));

    var spans = xmlDoc.documentElement.getElementsByTagName("span");

    var zoom = 17 - calculateZoomLevel(parseFloat(spans[0].getAttribute
("lng")), parseFloat(spans[0].getAttribute("lat")));

    document.getElementById('map').style.width = '100%';
    document.getElementById('map').style.height = 500;
    map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    new GKeyboardHandler(map);
    map.setCenter(new GLatLng(parseFloat(centers[0].getAttribute
("lat")), parseFloat(centers[0].getAttribute("lng"))), zoom);

// zoom is 0-17

//  lMessage = document.getElementById('lMessage');
//    alert("zoom level 100");

//    alert("finding markers");

    markers = xmlDoc.documentElement.getElementsByTagName("marker");

    window.setTimeout(mapOne, timeout)
    }
  }
request.send(null);
}

function createMarker(point, html, icon)
{
        var marker;

        if (icon == "generic")
        {
          marker = new GMarker(point);
        }
        else
        {
          baseIcon.image = icon;
          marker = new GMarker(point, baseIcon);
        }

  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
  });

  return marker;
}

function showCenter()
{
  var center = map.getCenterLatLng();
  var latLngStr = '(' + center.y + ', ' + center.x + ')';
  document.getElementById("centerCoords").innerHTML = latLngStr;
}

function showGMap(lat, lon)
{
    if (!map)
    {
      map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.addControl(new GMapTypeControl());
//      new GKeyboardHandler(map);
    }
    map.setCenter(new GLatLng(lat, lon), 13);
    var point = new GLatLng(lat, lon);
    var marker = new GMarker(point);
    map.addOverlay(marker);

    var polyOptions = {geodesic:true};var polyline = new GPolyline
([  new GLatLng(36.089444, -80.270278),  new GLatLng(lat,lon)  ],
"#ff0000", 10, 1, polyOptions);  map.addOverlay(polyline);


//    showCenter();
    GEvent.addListener(map, "click", function(overlay, point) {
    if (point) {
    var latLngStr = point.y + ' ' + point.x;
    document.getElementById("centerCoords").innerHTML = latLngStr;
  }
});

//function() { showCenter() });
}

function mapURL(mag)
{

 var lat = coords.getLat().toDec();
 var lon = coords.getLong().toDec();

  if (lat > 0)
  {

 if (mag == null)
 {
   mag = ".070";
 }

showGMap(lat, lon);

 }

}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to