目前,我正在使用原型(js)的面包房,绘制Gogle地图一皮五3。 我有一个叫作:TravelMapprManager
的栏目,有4个类别变量,有18个功能。
var TravelMapprManager = Class.create( {
// id of container
map_container : ,
/* the current map */
map : null,
/* geocoding location */
geocoder : null,
/* user entered locations */
user_journey : new Array(),
//many other functions [.....]
initialize : function( map_container ) {
this.map_container = map_container;
// start the map
Event.observe( window, load , this.displayMap.bind(this) );
// observe the map buttons
Event.observe( document, dom:loaded , this.initObservers.bind(this) );
},
/*
* Save the location entered
*/
findLocation : function() {
location_name = $( LocationName ).value;
if ( location_name == ) {
alert( "Please enter a location name." );
return;
}
// we only allow a maximum number of locations
if ( this.user_journey.length >= 20 ) {
alert( "Sorry! We have reached the maximum number of locations." );
return;
}
// Do geocoding, find the longitude and latitude of the location
if ( this.geocoder ) {
var current_o = this;
this.geocoder.getLatLng(
location_name,
function( point ) {
if ( !point ) {
alert( location_name + " not found" );
} else {
// store the location
current_o.storeLocation( location_name, point );
// center the location on the map and add push pin marker
current_o.map.setCenter( point, 13 );
var marker = new GMarker( point );
current_o.map.addOverlay( marker );
}
}
);
}
}
})
What does var current_o = this;
mean in the function findLocation?