Hi Guys,

I am using ajax to update the polyline on my Map. It works fine if the
polyline is from "Tokyo" to "London" But it will loops forever if it
is from "Tokyo" to "New York".

I notice that the problem happens if the polyline is drawn from Asia
to US.

And the problem arise in the following command:
      citymap.addOverlay(polyline_1);




My JS is as follows:

<script type="text/javascript">
var polyline_1 = new GPolyline(0,0, '#0000FF', 5, 0.4);

function addCodeToFunction(func,code){
    if(func == undefined)
        return code;
    else{
        return function(){
            func();
            code();
        }
    }
};


window.onload = addCodeToFunction(window.onload,function() {
if (GBrowserIsCompatible()) {
        citymap = new GMap2(document.getElementById("citymap"));
        citymap.setCenter(new GLatLng(37.775,-122.418),4);
        var mt = citymap.getMapTypes();

        }citymap.addControl(new GSmallMapControl());
});












/*********************** ajax functions ************************/
var xmlHttp;

function showMap()
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }

var url="/map/test_search_address_after_input";
url=url+"?edit_model="+document.getElementById("edit_model").value;
url=url+"&location0="+document.getElementById("location0").value;
url=url+"&location1="+document.getElementById("location1").value;

xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged()
{
if (xmlHttp.readyState==4)
{
eval(xmlHttp.responseText);
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

/*********** map common functions******************/





function clearDrawPolyline() {

  citymap.removeOverlay(polyline_1);
  var points = [];
  var lat = '';
  var lng='';

  var total = document.getElementById('destination_count').value;

  point = new GLatLng();


  for (var i = 0; i < total; i++ ) {
        lat = document.getElementById('destination' + i +
'_lat').value;
        lng = document.getElementById('destination' + i +
'_lng').value;

        if (lat!='' && lng!='') {
          point = new GLatLng(lat,lng);
          points[points.length] = point;
        }


  }


  if (points.length > 1) {


      polyline_1 = new GPolyline(points, "#0000FF", 5, 0.4);

      citymap.addOverlay(polyline_1);

  }
  return false;
}

</script>




And my Server side ajax just try to update a few input val then
trigger  the


clearDrawPolyline()



Any pointer is appreciated, thanks!
Arthur
--~--~---------~--~----~------------~-------~--~----~
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