google maps - Javascript setter function -


i creating class function in js following create new google maps.

i have problem having default value zoom variable , able change after object has been created.

here piece of code of function:

function gmap(lat,lng){     this.latitude = lat;     this.longitude = lng;     this.mapcenter = new google.maps.latlng(lat, lng);     this.map = null;     this.zoom = 20; // default value      this.setzoom = function(value)     {         this.zoom = value;     }        this.getzoom = function()     {         return this.zoom;     }        this.mapoptions = {         center: this.mapcenter,         zoom: this.zoom     };     this.createmap = function(htmlelement)     {         map = new google.maps.map(document.getelementbyid(htmlelement), this.mapoptions);         return this.map;     }   } 

i calling above this:

var gmap= new gmap(10, 20);      gmap.setzoom(9);  console.log(gmap.getzoom()); //returns 9  google.maps.event.adddomlistener(window, 'load', gmap.createmap('mapdiv')); //but creates map default zoom 20 

you have functions set or properties of map. think functions can modify zoom property. hope useful you.

google maps documentation v3


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -