kekscom / osmbuildings

OSM Buildings Classic 2.5D
http://osmbuildings.org
BSD 2-Clause "Simplified" License
505 stars 140 forks source link

Uncaught TypeError: Cannot read property 'addLayer' of undefined #71

Closed MarkCupitt closed 9 years ago

MarkCupitt commented 9 years ago

Just set up OSM Buildings with code at the bottom, and get the following error.

Using Latest download of the software from the web site ## 0.2.2b @ 2014-11-25

Since it works on the Demo Site, I am obviously missing something that is staring me in he face, I guess.

Scripts loaded in following order before calling the Js Code.

Cheers

Mark

Uncaught TypeError: Cannot read property 'addLayer' of undefined
OSMBuildings-OpenLayers.js:44 kmaps.js:125 (anonymous function)jquery.min.js:2 m.Callbacks.jjquery.min.js:2 m.Callbacks.k.fireWithjquery.min.js:2 m.extend.readyjquery.min.js:2 J

    arrayAerial = ["http://otile1.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg",
                    "http://otile2.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg",
                    "http://otile3.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg",
                    "http://otile4.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg"];

    map = new OpenLayers.Map(target_div, {
        projection: 'EPSG:3857',
        layers: [
            new OpenLayers.Layer.OSM(
                "OSM Base",
            ),
            new OpenLayers.Layer.OSM(
                "OSM Aerial",
                arrayAerial
            ),
        ], 
        center: new OpenLayers.LonLat(startLon, startLat)
            .transform('EPSG:4326', 'EPSG:3857'),
        zoom: Initial_Zoom,
        buffer: buffer

    });

    map.addControl(new OpenLayers.Control.LayerSwitcher());

    osmb = new OSMBuildings-OpenLayers(map).load();
MarkCupitt commented 9 years ago

Ok, I figured it out

The Example on the Web Site gave:

var osmb = new OSMBuildings-OpenLayers(map).load();

it SHOULD be:

var osmb = new OSMBuildings(map).load();

might want to fix those up .. :)

Cheers

kekscom commented 9 years ago

Thanks for spotting!