2

enter image description here

The above is my working directory, all html files are under WebContent folder and the problem is that when all the code is written in a single html file working fine. If I split the OpenLayers code into 'js' files under 'js' folder. The files within 'js' folder couldn't refer OpenLayers library(OpenLayers.js).

ReferenceError: OpenLayers is not defined So that var's not getting initialized.

{
<html>
    <head>

        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <link rel="stylesheet" type="text/css" href="ext-321/resources/css/ext-all.css" />

        <link rel="stylesheet" type="text/css" href="css/style.css" />

        <script type="text/javascript" src="ext-321/adapter/ext/ext-base.js"></script>

        <script type="text/javascript" src="ext-321/ext-all.js"></script>   
        <script type="text/javascript" src="js/geocoding.js"></script>

        <script type="text/javascript" src="js/map1.js"></script>
        <script type="text/javascript" src="js/tbar.js"></script>
        <script src="ol-211/OpenLayers.js"></script>
        <script src="ol-211/firebug.js"></script>
}

working with localhost. and calling init() method explicitly from Ext.onLoad() while I am calling with in the same page it works fine and there is no problem with map it is displaying

Ext.onReady(function(){
        Ext.QuickTips.init();
        Ext.BLANK_IMAGE_URL = "ext-321/resources/images/default/s.gif";
        // turn on validation errors beside the field globally
        Ext.form.Field.prototype.msgTarget = 'side';
        new Ext.Viewport({
        layout      :   'border',
        renderTo    :   Ext.getBody(),
        region  :   "center",
        //margins   :   '0 5 5 0',
        defaults:   {border:false},
        items       :   [{
            region  :   "center",
            layout  :   "fit",
            id      :   "center_region",
            /*//tbar    :   new Ext.Toolbar({//551
                            id: 'map-toolbar'
                        }),
            html    :   "<div id='map' style='height:100%;width:100%;'></div>"
            *///555//
            items   :[{
                xtype   :"tabpanel",
                id      :"tab_map_status",
                activeTab: 0,
                defaults    :   {border:false},
                items:[{
                            title   :   'Map',
                            id      :   'tab-map',
                            tbar    :   new Ext.Toolbar({
                                            id: 'map-toolbar',
                                            items: []
                                        }),
                            html    :   "<div id='map' style='height:100%;width:100%;'></div>" 
                        }]}]});init();});'

Please help me.

1
5

Change the order of your js-files. Load OpenLayers before the files within js-folder.

<script src="ol-211/OpenLayers.js"></script>
<script src="ol-211/firebug.js"></script>

<script type="text/javascript" src="js/geocoding.js"></script>
<script type="text/javascript" src="js/map1.js"></script>
<script type="text/javascript" src="js/tbar.js"></script>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.