TDownLoadRequest

(TDownLoadRequest.TDownLoadRequest Method)

Creates a TDowndloadRequest object. It retrieves the resource from then given URL and calls the onload function with the w3c http request object as first argument (see http://www.w3.org/TR/XMLHttpRequest/), and the HTTP response status code as the second (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
public TDownLoadRequest(urlToDownload:String,onLoadedCallbackFunction:Object):Void

Parameters

  • urlToDownload : String - Specify the url loaction where the resource from.
  • onLoadedCallbackFunction : Object - This onload function will be called with the w3c http request object specified by the url parameter.
  • Returns

  • Void
  • Example

    The following example creates a TDownloadRequest object in order to retrive a list of markers from a .xml file.
    <div id="mapContainer"  style="width: 640px; height: 400px;"></div>
    <script type="text/javascript">
        var map0 = new TMap(mapContainer, 25.7590256665386, -80.3738769902151, 15, mapInit, 1, true, "", "hybrid");
        downloadObj = new TDownloadRequest("http://maps.cs.fiu.edu/API_doc_stage/Terrafly_API_Prod/markers.xml", OnDataLoaded);
        function OnDataLoaded( http_request, status )
            { 
                if (http_request.status == 200){
                    var xmldoc = http_request.responseXML;
                    var doc = http_request.responseText;
                    var markers = xmldoc.documentElement.getElementsByTagName("marker");
                    if ( markers == null ){
                        return;
                    }
                    for (var i = 0; i < markers.length; i++) {
                        var latValue=parseFloat(markers[i].getAttribute("lat"));
                        var lonValue=parseFloat(markers[i].getAttribute("lng"));
                        var label=String(markers[i].getAttribute("label"));
                        var description=String(markers[i].getAttribute("description"));
                        marker[i] = layer0.AddMarker(latValue, lonValue,label);
                    }
                }
                else if( http_request.status != 0)
                {
                    alert("server is current busy or the number of results exceeds 3,000 in this area." + "\n Request to server Error code:" + status );
                }
                downloadObj = null;
            }   
    
    
    </script>
        

    Another Example

  • Using TDownloadRequest() function