Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Insert Coordinates from External File into BING Maps? Help!

tonyvidtonyvid Posts: 1Member
Hi everyone!

I seem to have a Javascript problem, probably due to sheer inexperience :-( . I'm trying to feed specific coordinates into Bing Maps' javascript. The coordinates come from a specific file on my web server (coords.txt).

The Javascript I have set up so far will read the coordinates file (coords.txt) and display it in text form within the HTML page. That's great (at least I know I don't have a file reading issue). The problem is with BING Maps. There are THREE specific places within Bing's JS code in which I need to feed the specific coordinates (they are denoted below with XXXXXX). But it's not working, and I don't know where to go next!

I guess my question is: How do I define a javascript variable THAT BING CAN USE from the contents of my coords.txt text file? Also, would you mind taking a peek at my code (below) and telling me if there are any problems with it?

The vision is to eventually utilize AJAX to dynamically update the map coordinates at ten second intervals, thus updating the map for web page visitors as soon as location updates become available. However, I can't even consider the time intervals part until I work this out!

P.S. Non-JS solutions (ex: server side includes) are not options.

Here's the code--
Note the following:
(A) The coords.txt file referenced below is very short and literally reads: "36.098985, -115.170500". That's it.
(B) I need the areas that contain XXXXXX to have the contents of coords.txt inserted there.
(C) The XXXXXX areas literally need a string that's formatted exactly like the contents of the coords.txt file.
(D) When I insert "36.098985, -115.170500" within the parentheses (without quotes), up comes a perfect map of Vegas (intentional).

Please help! I'm about to go nuts!!!


[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">




function ajaxFunction()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}

else if (window.ActiveXObject)
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}

else
{
alert("Problem! Your browser does not support XMLHTTP or AJAX!");
}

xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
document.getElementById('coords').innerHTML=xmlhttp.responseText;
}
}

xmlhttp.open("GET","coords.txt",true);
xmlhttp.send(null);
}

//BING Maps Start Here
var map = null;

var SpaceNeedle = new VELatLong(XXXXXXX);
var pinLocation = new VELatLong(XXXXXXX);

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

map.LoadMap(SpaceNeedle, 17);

// Let me know if a birdseye scene is available
map.AttachEvent("onobliqueenter", OnObliqueEnterHandler);
}

function OnObliqueEnterHandler()
{
if(map.IsBirdseyeAvailable())
{
var TopOfNeedle = new VELatLong(XXXXXXX);
map.SetBirdseyeScene(TopOfNeedle);
}
}







[/code]
Sign In or Register to comment.