【发布时间】:2011-12-02 19:52:21
【问题描述】:
我目前正在使用 cakephp 和 prototype.js 开发谷歌地图 api V3。我有一个名为:TravelMapprManager 的 javascript 类,它有 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 );
}
}
);
}
}
})
函数 findLocation 中的var current_o = this; 是什么意思?
【问题讨论】:
标签: javascript cakephp-1.3 prototypejs