Hi,

Your parameter is a string and not an object

var visor = new MyViewer('map'); 

Perhaps this will work:

        function MyViewer(div){
                this.container = document.getElementById(div);


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im
Auftrag von David Alda Fernandez de Lezea
Gesendet: Dienstag, 26. Januar 2010 17:23
An: openlayers users
Betreff: [OpenLayers-Users] How to create a map on the fly,by clicking a
button

Hello list, 

I'm trying to make a Gis Web Viewer and I need to generate a Map, after
clicking a link/button from one div, into another div. I've created an
Object class like this

function MyViewer(){

        
        var map;
        var container;
        
        
        this.MyViewer= MyViewer;
        
        
        function MyViewer(div){
                this.container = div;
                this.map = new OpenLayers.Map( div, {projection: new
OpenLayers.Projection("EPSG:23030"), units: 'm', maxExtent: new
OpenLayers.Bounds(460000, 4710000, 610000, 4820000), maxResolution:
292.96875});
                 
                ...layer definition...
                        
                map.zoomToMaxExtent();

                document.getElementById(this.container).style.visibility =
"visible";
        }
}

And my html looks like this:

#map { border-style: solid;
border-width: 1px;
margin: 0px auto;
width: 650px;
height: 450px;
position: relative;
float: right;
overflow: auto;
visibility: hidden;
}

....

<body>
<div id="cabecera">
<h2>header</h2>
</div>
<div id="body">
<script type="text/javascript">
                
        function init(){
                var visor = new MyViewer('map');
        }

</script>       
<a href="#" onclick="init();">ShowMap</a><br>

</div>
<div id="map">map...
</div>
</body>

...

But I get an error on line

document.getElementById(this.container).style.visibility = "visible";

Saying:

Uncaught TypeError: Cannot read property 'style' of null

Is it possible to do what I'm trying to do ??

Thanks.

 
 
Un saludo,
 
············································································
······

David Alda Fernández de Lezea
Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad
 
IKT
Granja Modelo s/n · 01192 · Arkaute (Araba)

············································································
······
Tlfnos.: 945-00-32-95                         Fax: 945-00.32.90
············································································
······
email: [email protected]                                web: www.ikt.es
············································································
······
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

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

Reply via email to