flash - Google map api in as3, StyledMapType -



flash - Google map api in as3, StyledMapType -

i having null reference exception when instantiating styledmaptype

var styles:array = [ new maptypestyle( maptypestylefeaturetype.all, maptypestyleelementtype.all, [ maptypestylerule.visibility( "on" ), maptypestylerule.hue( 0xff0000 ), maptypestylerule.saturation( 100 ), maptypestylerule.lightness( -50 ), maptypestylerule.gamma( 1.0 ) ] ) ]; var options:styledmaptypeoptions = new styledmaptypeoptions( { name: 'styled map', alt: 'style', minresolution: 2, maxresolution: 12 }); var styledmaptype:styledmaptype = new styledmaptype(styles, options);

i getting error:

typeerror: error #1009: cannot access property or method of null object reference. @ com.google.maps::styledmaptype() @ com::main/init() @ com::main()

but when omit line:

var styledmaptype:styledmaptype = new styledmaptype(styles, options);

program runs. please help me out. have been trying find solution , problem hours.

thanks

you need register event listener on map_ready , set code in listener. error happening because google map object not instantiated yet.

public function somefunction(): void { yourgooglemapobject.addeventlistener(mapevent.map_ready, onmapready); } private function onmapready(event:event):void { var styles:array = [ new maptypestyle( maptypestylefeaturetype.all, maptypestyleelementtype.all, [ maptypestylerule.visibility( "on" ), maptypestylerule.hue( 0xff0000 ), maptypestylerule.saturation( 100 ), maptypestylerule.lightness( -50 ), maptypestylerule.gamma( 1.0 ) ] ) ]; var options:styledmaptypeoptions = new styledmaptypeoptions( { name: 'styled map', alt: 'style', minresolution: 2, maxresolution: 12 }); var styledmaptype:styledmaptype = new styledmaptype(styles, options); }

flash actionscript-3 google-maps

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -