Intelliorbit


I am trying to add a pushpin on my map and it is not being displayed even after reading all the articles on pushpin. I am referencing an exterenal javascript file. Here is the code.

<!--
var map = null;


window.onload = function GetMap() {
map = new VEMap('myMap');
map.LoadMap(new VELatLong(33.61959, -111.897649), 15 ,'R' , false);
}

var pushpin = new VEPushpin('1', //Id - must be unique
new VELatLong(33.61959, -111.897649), //latitude, longitude
null, //icon url
'Scottsdale Jean Company', //Title
'Jean Store' //Notes
);

map.AddPushpin(pushpin);

// -->


Then my html has

<div id='myMap' style="position:relative; right:-60; width:500px; height:400px;"></div>
Please help! Thanks!



Re: Pushpin is not being shown....

SoulSolutions


So your page is loading, it runs your javascript that waits to load the map until the window loads but then goes and adds your pushpin before the map load

should you not put your map.AddPushpin() inside you GetMap() function after the loadmap to get the order right

John.







Re: Pushpin is not being shown....

Intelliorbit

I have tried that and it just gives me an error. It actually doesn't even load the map then. Please Help!






Re: Pushpin is not being shown....

Derek Chan

Here I rebuilt what you wanted to do in another html file.

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"></script>
<script>
var map = null;
var pinID = 1;

function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
AddPin();
}

function AddPin()
{
var pin = new VEPushpin(
'1',
new VELatLong(33.61959, -111.897649),
null,
'Scottsdale Jean Company',
'Jean Store'
);
map.AddPushpin(pin);
pinID++;
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>





Re: Pushpin is not being shown....

Intelliorbit

Thanks! I am trying to use the window.onload = function GetMap() and it won't display it. Do you think that is the reason why it is not loading I will try it like yours in the body tag.




Re: Pushpin is not being shown....

Derek Chan

Just do it on the body.onload should be fine. Thats probably causing the problem




Re: Pushpin is not being shown....

Gomfucius

Hi, I am having the same problem. It is not working on IE or Firefox 2.x.
Both

<body onload="GetMap();">

and

window.onload = function()
{
GetMap();
AddPin();
}

seems to work on Firefox 1.5 but not on IE and Firefox 2.
Is there any way around this
Thank you.





Re: Pushpin is not being shown....

Gomfucius

I found this link, after doing this, the pushpin appeared okay.

Currently Virtual Earth doesn't detect the version of Firefox properly. This hack will get things working:

http://www.viavirtualearth.com/Wiki/Firefox2.ashx