GeoffNin

I put the following code in a content webpart and though the space for the div tag is given the map doesnt render.

HALP ME INTERTRON!

Code Block

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx =5"></script>
<script language="javascript" type="text/javascript" >
var map = null;
var Marks = [];

function userobject(pName, pComments){
this.Name = pName
this.Comments = pComments
}

function AddPushpin()
{
var shape = new VEShape(VEShapeType.Pushpin, map.GetCenter());
shape.SetTitle('My pushpin');
shape.SetDescription('This is shape number ');
map.AddShape(shape);
}

function GetMap()
{
//Dispose the map if it was previously loaded.
if (map!=null){
map.Dispose();
}

for(i = 0; i < 4; i++){
Marks[i] = new userobject("object " & i, "comment " & i);
}



map = new VEMap('myMap');
map.SetDashboardSize(VEDashboardSize.Normal);
map.LoadMap(new VELatLong(37.8225, -122.17822),12,'r',false,VEMapMode.Mode2D,false);
var tileSourceSpec = new VETileSourceSpecification("tilelayer", "http://%1%2.ortho.tiles.virtualearth.net/tiles/%3%4 g=%6&shading=hill");
tileSourceSpec.MinZoomLevel = 1;
tileSourceSpec.NumServers = 1;
tileSourceSpec.MaxZoomLevel = 18;
tileSourceSpec.Opacity = 1.0;
tileSourceSpec.ZIndex = 1;
map.AddTileLayer(tileSourceSpec, true);
AddPushpin();



//map.SetMapStyle(VEMapStyle.Aerial);
// map.LoadMap(new VELatLong(37.8225, -122.17822),16,'a',false, VEMapMode.Mode3D,false);
// map.SetPitch(-33);
// if (map != null){
// map.Dispose();
// }
// map = new VEMap('myMap');
// // map.HideDashBoard();
// // map.SetDashboardSize(VEDashboardSize.Small);
// map.LoadMap(new VELatLong(37.8225, -122.17822),16,'a',false, VEMapMode.Mode3D,false);
// map.SetPitch(-33);

}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:525px; height:400px;"></div>


</body>
</html>




Re: SharePoint - Development and Programming Live Search not rendering

Dave_Lepre

I am having a similar problem. What I think the problem is, is that body onload = "GetMap()" does not invoke the j script. Try putting in a window.alert at the top of your GetMap function. You will see that window.alert does not fire. I need a way to invoke J Script in a web part to change the img src. Similar to what you are doing with id='myMap'.

If anyway know how to invoke the J script in the body onload, please let us know. If you put this into a htm page and not a web part, it works fine.





Re: SharePoint - Development and Programming Live Search not rendering

Dave_Lepre

I figured it out. Right after your <script language="javascript" type="text/javascript" > line, place the follwing line:

_spBodyOnLoadFunctionNames.push("GetMap");

Get rid of your body onload="GetMap()". Loading a jscript function in the body onload will not work. See attached link as to why

http://64.233.169.104/search q=cache:8tcIWSWuUXwJTongue Tiedharepointsolutions.blogspot.com/2007/07/adding-javascript-to-content-editor-web.html+changing+img+src+and+webpart+and+javascript&hl=en&ct=clnk&cd=2&gl=us

Hope this helps. I wasted an entire day trying to figure this out.