﻿function GetVELongLat()
{
    //we have to get the long lat as reported by VE.  The VE long/lat precision is different from the zip code provider
    //since we have to know if a marker exists for a particular long/lat when they search for a city/state, we have to have
    //the same data source for long/lat in both functions.
    
    //this function goes and gets the long/lat as reported by VE for a particular city & state/prov and stores it in hidden fields on the form.
    
    var s = document.form1.ddUsStates.selectedIndex;
    var stateProvince = document.form1.ddUsStates.options[s].text;
    
    if (document.form1.rbCa.checked == true)
    {
        s = document.form1.ddCaProvinces.selectedIndex;
        stateProvince = document.form1.ddCaProvinces.options[s].text;
    }
    
    var txtSearch = document.form1.txtCity + ", " + stateProvince;
    
    if (txtSearch != "")
    {
        map.Find(null, txtSearch, null, null, null, null, null, null, false, null, GetLongLatCallback);
    }
}

function GetLongLatCallback(shapeLayer, findResults, places, moreResults, errorMsg)
{
    document.form1.txtLon.value = "";
    document.form1.txtLat.value = "";
    
    if (places)
    {
        document.form1.txtLon.value = places[0].LatLong.Longitude;
        document.form1.txtLat.value = places[0].LatLong.Latitude;
    }
}