Select to view content in your preferred language

map.centerAt(mapPoint) null object reference

2128
2
05-16-2011 03:24 AM
paoloanghileri
New Contributor
I have adapted a code for finding a place, setting a graphic point and zooming into it.
//////////////////////////////////////////////////////////////////////

var myGraphic:Graphic = new Graphic();
const mapPoint:MapPoint = new MapPoint();

//mapPoint.spatialReference.wkid=3003;
mapPoint.x=parentApplication.objCmpCollections.acCollectionSite[0].latitude;
mapPoint.y=parentApplication.objCmpCollections.acCollectionSite[0].longitude;;

myGraphic.geometry = mapPoint;
//myGraphic.geometry.spatialReference.wkid=3003;
myGraphic.symbol = mySymbol;                       
myGraphic.id = "graphic";
myGraphicsLayer.add(myGraphic);

map.scale=15000;
map.centerAt(mapPoint);

///////////////////////////////////////////////////////////////////////////

When I am debugging it in flex builder I get a 1009 null object reference error at the last line. The map correctly displays the graphic symbol in the correct place and does the scale.
So map is not null, mapPoint is not null.

Can anybody help me in pointing out this error?

Thanks a lot for your help
Paolo, Lake Como, Italy
Tags (2)
0 Kudos
2 Replies
RobertMyers
Deactivated User
0 Kudos
RhysDonoghue
Deactivated User
hi Paolo

Not sure if you have got your answer yet.  I am a Flex newbie but my understanding is your map needs to have an extent defined first before your code will work.  Let me know if you need help rhys.donoghue@splicegroup.co.nz

Rhys
0 Kudos