[OpenLayers-Users] Another Dumb Question?
Eric Lemoine
eric.c2c at gmail.com
Mon Sep 1 15:24:57 EDT 2008
Hi. $ is a function returning the DOM object corresponding to the id
passed as a parameter. It comes from the prototype library, so it's
expected that you won't find it in a js book. OpenLayers defines it in
Util.js, where it also defines an equivalent function, namely
OpenLayers.Util.getElement. The latter, belonging to the OpenLayers
namespace, is to be preferred. You're correct to say that
OpenLayers.Map("map") would work as well, OpenLayers being clever
enough to accomodate both types. Eric
2008/9/1, Bill Thoen <bthoen at gisnet.com>:
> In the example
> http://openlayers.org/dev/examples/custom-control-point.html, the line
> that says:
>
> map = new OpenLayers.Map( $('map') );
>
> I suppose this must return a reference to a div named 'map' but why wrap
> it in such a weird function? Wouldn't
>
> map = new OpenLayers.Map( "map" );
>
> work just as well?
>
> I'm still pretty new to JavaScript and OpenLayers but I can't find a
> reference to the function $() in my 5 lb JavaScript book (it's amazing
> what's NOT in the Rhino book!) nor can I find it in the OpenLayers docs.
> And Google seems to have a mental block against searching for anything
> that looks like punctuation even if I try "$()".
>
> I'm especially curious because I also saw a reference to "library
> dependence on $" in the recent discussion about OpenLayers and jQuery,
> and don't know what it means.
>
> So would somebody kindly clue me in on this one too?
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list