[OpenLayers-Users] Result of expression 'map' [undefined] is not an object.

P Kishor punk.kish at gmail.com
Sun Oct 4 19:00:58 EDT 2009


On Sun, Oct 4, 2009 at 12:13 PM, Andreas Hocevar <ahocevar at opengeo.org> wrote:
> Also make sure that you don't have extra commas at the end of object
> definitions.
>

if you mean, do like this

var foo = { a: 'blah', b: 'blech' };

and not like

var foo = { a: 'blah', b: 'blech', };

let me ask you, why not? Javascript doesn't mind, and it makes my
programming a lot easier to let there be a comma at the end.




> Regards,
> Andreas.
>
> Stephen Woodbridge wrote:
>> Nicholas Efremov-Kendall wrote:
>>
>>> Hi all,
>>>
>>> I'm getting the following error in what used to be functional
>>> code Result of expression 'map' [undefined] is not an object.
>>>
>>> It's breaking on the statement map.addLayer(cities). Here's the exerpted
>>> code that I've added around this. I can add a stripped down version of
>>> the rest, but it's bulky and I've only messed with the following bits.
>>> Any suggestions as to what's causing this error?
>>>
>>> var styleMap = new OpenLayers.StyleMap(
>>> {'default':OpenLayers.Util.applyDefaults(
>>> {
>>>       label: '${Name}',
>>>       strokeWidth:1,
>>>       strokeColor:"#CCCCCC",
>>>       fillColor: "green",
>>> })
>>> }
>>>    );
>>> };
>>>
>>> var cities = new OpenLayers.Layer.GML
>>> ("7th Century Cities", "data/cities.gml",
>>> {
>>> styleMap: styleMap,
>>> projection: new OpenLayers.Projection("EPSG:4326"),
>>> format: OpenLayers.Format.GML,
>>> label: "${Name}",
>>> }
>>> );
>>> map.addLayer(cities);
>>>
>>
>> Where is "var map" defined. It sounds like it is not in the visible
>> scope of the above code.
>>
>> -Steve W
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================
Sent from Madison, WI, United States



More information about the Users mailing list