[Javascript] Anonymous functions
Nick Fitzsimons
nick at nickfitz.co.uk
Tue Dec 4 13:43:09 CST 2007
On 4 Dec 2007, at 18:51, Terry Riegel wrote:
> var listener = GEvent.addListener(map, "moveend", function()
> { document.getElementById("mapinfo").innerHTML="Zoom: "+map.getZoom
> ()+" Bounds: "+map.getBounds(); GDownloadUrl(url, function(data,
> status) { markers=eval(data); map.clearOverlays(); for (var i in
> markers) { var where = new GLatLng(markers[i].lat, markers[i].lng);
> var opts = {title: markers[i].title}; var marker = new GMarker
> (where, opts); map.addOverlay(marker); } }); });
>
>
> I would like to take the first function() {...} and make it a named
> function, but when I do it I get something like map undefined. How
> do I un-anonymous-ize a function?
You should be able to use
var listener = GEvent.addListener(map, "moveend", function
myNamedFunction() {
without any problem. Does that not work?
Regards,
Nick.
--
Nick Fitzsimons
More information about the Javascript
mailing list