Rod Yager


I am servering up the VE.htm via a embeded WebBrowser control in a windows forms app. The map renders fine but when I manually try to pan using the mouse, I get tons of javascript errors. If I use the arrow controls for the map it works fine without errors. Also if I clear out IE temporary files cache just prior to rendering the map, panning works fine. Subsequent times I will get the errors again. The is v6 of the control. Any ideas. I have IE's setting to Check webpages for newer version every time I visit page and the setting to Empty the temporary files directory when the browser is closed under the advanced tab.

If I bring this htm page up in IE and not the WebBrowser control, I don't get the errors.




Re: Get javascript error 'null' is null or not an object when panning on simple map render.

stanM


Rod,

I am having similar type of a problem with WebBrowser control.

I wrote a user control with the web browser control in it and everything works fine in V5 but when I switched to V6

all those 'null' is null or not an object started to pop up in different situations not only

on pan but on mouse move too.

Especally often it happens if I dynamically create a second control on one winform.

Up until I've read your message I thought this is all my code now I am starting to think Microsoft.

MS people please give us an answer or a work around.

Thanks,

Stan






Re: Get javascript error 'null' is null or not an object when panning on simple map render.

Rod Yager

Glad to hear that I am not the only one. Stan, what I ended up doing so that I could continue to develop is to set

webBrowserCtrl.ScriptErrorsSuppressed = true; The map seems to behave the way it should.

Hey, since we are working on something similar, do you know how to create a javascript method to add a VELatLong object to an array I have a loop in my c# code to add points and then would like to call map.GetDirections using the VELatLong array object. Doesn't seem to work.

var locations = new Array();

function addRoutePoint(address1,city,state,zip,country,mLat,mLong,infoTitle,infoContentHtml,iconUrl,iconLabel)

{

if (mLat == 0 && mLong == 0)

{

locations.add(address1 + city + state + zip);

}

else

{

var latLongObj = new VELatLong(mLat,mLong,0,VEAltitudeMode.Default);

locations.add(latLongObj);

}

}

function renderRoute(r,g,b)

{

var options = new VERouteOptions;

options.DrawRoute = true;

options.SetBestMapView = false;

options.DistanceUnit = VERouteDistanceUnit.Mile;

options.ShowDisambiguation = true;

map.GetDirections(locations, options);

}

Thanks,

Rod






Re: Get javascript error 'null' is null or not an object when panning on simple map render.

stanM

Rod,

I wish I new why your code is not working but this what I do :

My app is a tracking one. I do not use arrays of VELatLong I create layers and add shape to a layer one by one

using my internal collections of objects with properties

Basically I do the following:

1 Create an array of objects I call them units

2. Create a unit define properties like internal map ID, lat, lon, alt etc and set them at the creation time ~ like that

so unit is like a class:

function OLUnit()

{

var m_unitInternalId=null;

this.GetUnitInternalId=GetUnitInternalId;

function GetUnitInternalId(){return m_unitInternalId;}

this.SetUnitInternalId=SetUnitInternalId;

function SetUnitInternalId(id){m_unitInternalId=id;}

var m_unitId=null;

this.GetUnitId=GetUnitId;

function GetUnitId(){return m_unitId;}

this.SetUnitId=SetUnitId;

function SetUnitId(id){m_unitId=id;}

var m_unitDisplayId=null;

this.GetUnitDisplayId=GetUnitDisplayId;

function GetUnitDisplayId(){return m_unitDisplayId;}

this.SetUnitDisplayId=SetUnitDisplayId;

function SetUnitDisplayId(id){m_unitDisplayId=id;}

var m_unitLat=null;

this.GetUnitLat=GetUnitLat;

function GetUnitLat(){return m_unitLat;}

this.SetUnitLat=SetUnitLat;

function SetUnitLat(lat){m_unitLat=lat;}

var m_unitLon=null;

this.GetUnitLon=GetUnitLon;

function GetUnitLon(){return m_unitLon;}

this.SetUnitLon=SetUnitLon;

function SetUnitLon(lon){m_unitLon=lon;}

Etc...

}

===========================================================

here i Render a unit - update the position like that

var olUnit=this.GetUnitById(id);

if(olUnit==null)

{

olUnit=new OLUnit();

olUnit.SetUnitId(id);

this.m_units.push(olUnit);

}

olUnit.SetUnitDisplayId(displayid);

olUnit.SetUnitLat(lat);

olUnit.SetUnitLon(lon);

olUnit.SetUnitDatetime(datetime);

alt=parseInt((parseInt(alt)));

if(isNaN(alt))

alt=0;

if(alt<0)

alt=0;

if(speed==0)

alt=0;

olUnit.SetUnitAlt(alt*0.3048);

olUnit.SetUnitSpeed(speed);

olUnit.SetUnitHdng(hdng);

-- some code for setting icons etc...

//shape layer already created so it renders added/updated unit

if(olUnit.GetUnitInternalId()==null)

{unit = new VEShape(VEShapeType.Pushpin, [new VELatLong(lat,lon)]);

unit.SetAltitude(alt,VEAltitudeMode.Absolute);olLayers.unitsLayer.AddShape(unit);

olUnit.SetUnitInternalId(unit.GetID());

}

else

{

unit=olLayers.unitsLayer.GetShapeByID(olUnit.GetUnitInternalId());

unit.SetPoints([new VELatLong(lat,lon)]);

unit.SetAltitude(alt,VEAltitudeMode.Absolute);

}

3 Add/delete/update a unit from units array using push / pop; searching units array by say internal map id and returning a unit

Regards,

Stan





Re: Get javascript error 'null' is null or not an object when panning on simple map render.

RickLH

I was having exactly the same symptom - pan using the dashboard panel gadget worked but a cursor pan generated a js exception, complaining of a null object. It turned out that to be a misspelling.

Code Block

// Was

map = new VEMap('myMap');

map.LoadMap( new VELatLong(lat_a, lon_a),

4,

VEMapStyle.AHybrid, // Should have been 'VEMapStyle.Hybrid'!

false,

VEMapMode.Mode2D,

false,

1);






Re: Get javascript error 'null' is null or not an object when panning on simple map render.

Rod Yager

Unfortunately I am just doing a map.LoadMap() without any parameters.

Rod





Re: Get javascript error 'null' is null or not an object when panning on simple map render.

RobertoRaimondo

Hello Rod,
I replied to Richard on a similar problem in this post. You may want to take a look at it, I hope it may help you find the cause of your problem, or give you some idea to investigate on it.
Roberto.




Re: Get javascript error 'null' is null or not an object when panning on simple map render.

RickLH

In my case, the real problem turned out that I was creating the map multiple times. It appears that the DocumentCompleted notification may be called twice. In my case, I moved the map creation trigger into the HTML body's onload event and then did not need to call the map creation from DocumentCompleted at all. Since your map creation takes no arguments, that is probably the easiest thing for you to do as well. I'm sure that Roberto's suggestion would have worked as well, which used a private member to ensure that the the DocumentCompleted notification only called the javascript function that creates the map a single time.






Re: Get javascript error 'null' is null or not an object when panning on simple map render.

RobertoRaimondo

Richard is right, it doesn't change too much where you put it. However I have several tasks performed in my DocumentCompleted handler on the C# side, so I needed a way to execute it only once. That flag is also used somewhere else in the C# code. If you don't have too much to do there, you can simply put the check in the JS code.

Roberto.