views:

338

answers:

1

I have latitude and longitude saved inside a database. I have the bing map loading and I can set the VELatLong using regular values but can't seem to be able to load them from the database. Whatever I try the map just doesn't show at all.

<script type="text/javascript">
    var map = null;
    var selStyle = VEMapStyle.Road;
    var selMode = VEMapMode.Mode2D;
    var zoom = 14;

    var latLon = new VELatLong(40.67959657544238, -73.94073486328126); // NYC, NY

    var locationPin = null;

    function GetMap() {
        map = new VEMap("myMap");

        map.onLoadMap = InitialPin;

        map.SetCredentials("--KEY HERE--");
        map.LoadMap(latLon, zoom, selStyle, false, selMode, false);
        map.AttachEvent("onclick", OnClick_PinHandler);
    }
    window.onload = GetMap;
    window.onunload = DisposeMap;
</script>

Thanks for your help!

+2  A: 

I used a hidden field to load the coordinates from the database into the page. Then I use the following JaveScript function to set the location of the map.

function SetLocation() {
    var latitude = $("#latitude").val();
    var longitude = $("#longitude").val();

    var location = new VELatLong(latitude, longitude);

    map.SetCenter(location);
}
Lukasz