Okay, if I do what Mr. Swingley suggest, my firebug fire the TypeError: node is nullin the index.html :<script type="text/javascript">
dojo.require("esri.map");
oData = {
"nom":"Coaticook",
"extent":
{
"xmin": -8007750,
"ymin": 5622181,
"xmax": -7978153,
"ymax": 5647140
}
};
var oMapper = new Mapper(oData);
oMapper.init();
dojo.ready(oMapper.initMap);
</script>
in the mapper class :function Mapper(oData)
{
this.map;
this.div_map;
this.init = init;
this.builDivs = buildDivs;
this.oData = oData;
this.initMap = initMap;
function init()
{
buildDivs();
}
function buildDivs()
{
this.div_map = $('<div id="map"></div>');
$('#main').append(this.div_map);
}
function initMap()
{
var initialExtent = new esri.geometry.Extent({
'xmin': oData.extent.xmin,
'ymin': oData.extent.ymin,
'xmax': oData.extent.xmax,
'ymax': oData.extent.ymax,
'spatialReference': new esri.SpatialReference({ wkid: 102100 })
});
this.map = new esri.Map("map",
{
basemap:"topo",
extent: initialExtent,
"fadeOnZoom": true,
logo: true,
showAttribution: false
});
}
}
If i take the suggestion of Mr. Jgravois, it doesn't seem to be a javascript OOP.BUT with some workaround of my original code, it works.index.html :
<script type="text/javascript">
dojo.require("esri.map");
oData = {
"nom":"Coaticook",
"extent":
{
"xmin": -8007750,
"ymin": 5622181,
"xmax": -7978153,
"ymax": 5647140
}
};
dojo.ready(function()
{
var oMapper = new Mapper(oData);
oMapper.init();
oMapper.initMap();
});
</script>
mapper class :
function Mapper(oData)
{
this.map;
this.div_map;
this.init = init;
this.builDivs = buildDivs;
this.oData = oData;
this.initMap = initMap;
function init()
{
buildDivs();
}
function buildDivs()
{
this.div_map = $('<div id="map"></div>');
$('#main').append(this.div_map);
}
function initMap()
{
var initialExtent = new esri.geometry.Extent({
'xmin': oData.extent.xmin,
'ymin': oData.extent.ymin,
'xmax': oData.extent.xmax,
'ymax': oData.extent.ymax,
'spatialReference': new esri.SpatialReference({ wkid: 102100 })
});
this.map = new esri.Map("map",
{
basemap:"topo",
extent: initialExtent,
"fadeOnZoom": true,
logo: true,
showAttribution: false
});
}
}