Hey guys, I'm new to javascript and I'm playing to understand this language, I object-oriented Javacript I I am trying to prepare a small script, but I have no problem, what I have to share with me.
Actually I have this library which I am making, a little bit, I have the following function. (My Library is in Mapster.js):
addMarker: function (opts) {var marker; Opts.position = {lat: opts.lat, lng: opts.lng} marker = this._createMarker (opts); If (opts.event) {this._on ({obj: marker, incident: opts.event.name, callback: opts.event.callback}); } Return marker; },
So basically the marker returns to the above function
Now in my script.js, in which file I actually own my library of Mapster.js I have the following lines of code:
Map. AddMarker ({lat: 15.498 9, lng: 73.8278, draggable: true, visible: true, // false is false and the marker event will disappear: {name: 'click', callback: function () {alert ('yups I am gautam ');}}}); Var infoWindow = New google.maps.InfoWindow ({Content: 'I'm on a map'}); InfoWindow.open (map.gMap, marker); // I get an error saying the reference error: the marker is not defined
It is well enough, I asked one of my greatest vantage and he said the following:
As the message says, you have not defined the marker In AddMarker you create it and return it, but you are not specifying the returned value in the calling script.
I think he had given it to Enver, but I am still struggling with, "How can I store the return value in the calling script, IE script. ".
I would really be great if someone can answer this question for me
thanks
Alexander
You only need to specify the result of addMarker
in a variable:
< Code> var marker = map.addMarker ({lat: 15.498 9, lng: 73.8278, dragable: true, visible: true, // it is wrong and the marker will disappear from the event: {name: click}, callback: Function () {Alert ('UPS I Gotam');}}}); InfoWindow.open (map.gMap, marker);
No comments:
Post a Comment