Hi, You're calling test() in the body of your page. But test() itself refers to map, which will be defined in the initialize() function. Because initialize() is executed after the page is loaded, you can't call test() in your body (ie before the onload event).
Mathieu On Jul 2, 1:11 pm, Adriano Ellero <[email protected]> wrote: > yes i did that. ok i write all the code entirely in order to avoid > misunderstanding. > first of all, thanks a lot for your support... > > <%@ LANGUAGE="VBSCRIPT" %> > > <!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <meta http-equiv="content-type" content="text/html; charset=utf-8"/> > > <title>meain</title> > > <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAADc9fglFK..." > type="text/javascript" > > </script> > > <script type="text/javascript" language="javascript"> > var map; > var MRK; > var Adriano = "vedi che va" > > function initialize() { > if (GBrowserIsCompatible()) { > map = new GMap2(document.getElementById("map_canvas")); > map.setCenter(new GLatLng(46.798333333333,12.8833333333333),07); > map.setUIToDefault(); > map.setMapType(G_PHYSICAL_MAP); > > } > } > > function test(){ > > MRK = new GIcon(); > MRK.image = "/images/mrk.png"; > MRK.iconSize = new GSize(24, 24); > MRK.iconAnchor = new GPoint(6, 6); > MRK.infoWindowAnchor = new GPoint(5, 5); > var LL = new GLatLng(46.798333333333, 12.8833333333333); > var marker = new GMarker(LL, { title: "123", icon: MRK }); > > var overlay = map.addOverlay(marker); > alert("done"); > } > > function TestMsg(prova) { > > alert(prova); > alert( Adriano ); > } > > </script> > </head> > > <body onload="initialize()" onunload="GUnload()" style=" width:650px; > text-align:center; vertical-align:middle" onclick="test()"> > <script type="text/javascript" language="javascript"> > > document.write ("<div id='map_canvas' > style='width:600px;height:500px;'></div>"); > </script> > > asdfasdf > > <script type="text/javascript" language="javascript"> > > test(); > </script> > > </body> > </html> > > 2009/7/2 Andrew Leach <[email protected]> > > > > > > > > > On Jul 2, 10:34 am, Adriano Ellero <[email protected]> wrote: > > > this function call makes error "map in null or not an object" > > > > sorry is more clear now? > > > You declare "map" with > > var map; > > but you assign it a value in your function "initialize". You never > > call initialize(), so the variable remains null. > > > If that doesn't help, you need to post a link. Code snippets are > > inconclusive. > > > Andrew > > -- > Adriano Ellero > [email protected] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
