If you look at the OpenLayers.Map constructor it is asking for two parameters; the first being the "div" to render the map, and the second being a list of options. By using
new OpenLayers.Map({div: "map", controls: [geolocate], layers:
[layer]});
You are actually passing in an object literal as the first parameter where OL is expecting a div id reference.


Troy


On 11/24/2011 15:21 PM, jns wrote:
Hi, 

I apologize if this isn't the correct forum for my sort of question. But I'm
very new to this and I will however give it a try.

This line of code will render the map just as it is supposed to do:

map = new OpenLayers.Map({div: "map", controls: [geolocate], layers:
[layer]});

... but shouldn't the following lines give me the same result?

map = new OpenLayers.Map("map");
map.addControl(geolocate);
map.addLayer(layer);

I thought they were equivalent to the above statement, but apparently not
since no map is rendered. I use jQuery Mobile if it may make any differences

Thanks,
Jonas

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/OpenLayers-syntax-issue-tp7029250p7029250.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

--
Troy Coburn
Web Developer
CARIS
115 Waggoners Lane
Fredericton, New Brunswick
Canada    E3B 2L4
Tel: +1.506.458.8533     Fax: +1.506.459.3849
www.caris.com

Join us for CARIS 2012 — Exploration and Discovery
June 25–28, 2012, Vancouver, British Columbia, Canada
Visit www.caris.com/caris2012 for details today

Connect with CARIS
Twitter LinkedIn FaceBook YouTube

Download your free copy of CARIS Easy View today!
www.caris.com/easyview

_________________________________________________________________________
This email and any files transmitted with it are confidential and intended only for the addressee(s). If you are not the intended recipient(s) please notify us by email reply. You should not use, disclose, distribute or copy this communication if received in error.

Any views or opinions expressed in this email are solely those of the author and do not necessarily represent those of the company. No binding contract will result from this email until such time as a written document is signed on behalf of the company.

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to