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

Roald de Wit roald.dewit at lisasoft.com
Mon Oct 5 01:02:57 EDT 2009


Hi,

On 05/10/09 14:53, P Kishor wrote:
> On Sun, Oct 4, 2009 at 10:44 PM, Stephen Woodbridge
> <woodbri at swoodbridge.com>  wrote:
>
>> Kishor,
>>
>> I'm pretty sure that the trailing common is not portable across browsers, as
>> I'm sure I have had problems with that in the past. It is a common model
>> that I learned in Perl, but it is not supported by most other languages. :(
>>
> Yup, I too picked up that good habit in Perl, and thoroughly enjoy
> being lazy with it. That said, I am doing development right now and
> testing in both Safari 4.x and Firefox 3.5x, and the trailing comma
> seems to work fine. I don't have access to any version of IE (well,
> not easily anyway) so I haven't really tested.
>
> Can someone please confirm the browsers/versions in which the trailing
> comma croaks?
>

This is a confirmation: using a trailing comma in an object (curly
brackets) is an easy way to bring IE6/7/8 to its knees and hard to debug
without developer tools.
Any other browser (that I know of) has no issues with it, only IE.

Regards,

Roald


>
>
>> -Steve
>>
>> P Kishor wrote:
>>
>>> 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
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>


--
Roald de Wit
Software Engineer
roald.dewit at lisasoft.com

Commercial Support for Open Source GIS Software
http://lisasoft.com/LISAsoft/SupportedProducts/



The contents of this email are confidential and may be subject to legal or professional privilege and copyright. No representation is made that this email is free of viruses or other defects. If you have received this communication in error, you may not copy or distribute any part of it or otherwise disclose its contents to anyone. Please advise the sender of your incorrect receipt of this correspondence.



More information about the Users mailing list