I had some variables and functions to work with google maps, that are working great, but i needed to have more than one map in the same page, and was using different names to each variable, like xml1, xml2. But decided to use a object to group all variables and functions.
Expand|Select|Wrap|Line Numbers
- function Map(){
- this.xml;
- this.loadMap = function (tabId){
- this.myElement = $(tabId);
- if (GBrowserIsCompatible()) {
- this.map = new GMap2(this.myElement.getElementsByClassName("googlemap")[0]);
- ...
- this.getCells(tabId);
- }
- }
- this.getCells = function(){
- GDownloadUrl("request.php?script=genxml.php", function (data){
- this.xml = GXml.parse(data);
- this.redraw();
- });
- this.redraw = function (){
- alert("ok");
- //code to draw cells
- }
- }
Expand|Select|Wrap|Line Numbers
- map1= new Map();
- map1.loadMap(tabId);
"this.redraw is not a function"
and map1.xml is empty.
I don´t have many experience with objects in Javascript
Can anyone help me?
thx