I have a code snippet that's working for my "maps" feature - following is the code:
var latlang = new google.maps.LatLng(myjsonobject[pos].geocode.latitude, myjsonobject[pos].geocode.longitude);
$('#map_canvas').gmap({
'center': latlang,
'zoom': 10,
'disableDefaultUI':false,
'callback': function() {
var self = this;
self
.addMarker({'position': this.get('map').getCenter() })
.click(function() {
self.openInfoWindow({ 'content': address }, this);
});
}
});
The variable latlang
is provided with the latitude and longitude of a given location. Then, the map_canvas
is the div where the Google map is displayed with the latlang
as its inputs.
In the callback function, self
is a variable assigned with this
. This is the place where I am confused. What is this
in this context? Can anyone throw some light on getCenter()
and the this
inside self.openInfoWindow
please?
How is the whole code working and showing me the result?