PDA

View Full Version : Google Maps Marker Adder



Gamer
5 Nov 2010, 10:03 AM
Trying to create a marker adder button that I can toggle on and off and will allow me to place markers wherever I want on the map
text: 'Add Marker',
id: 'test_button',
handler: function(button){
this.toggle();
console.log(button);
if (button.pressed == true){
//adds marker when you click on location
function addMarker(location) {
console.log(location);
marker = new this.gmap.Marker({
position: this.location,
map: this.gmap
});
markersArray.push(this.marker);
}
markerAdder: google.maps.event.addListener(this.gmap, 'click', function(event) {
addMarker(event.latLng);
});
}

}
}
these are the console errors Im getting. Im unsure of what im doing incorrectly, any help is appreciated.
Uncaught TypeError: Cannot read property '__e3_' of undefined
Zd
Xd
S.addListener
button.on.mapwin.Ext.Window.items.buttons.handler
Ext.Button.Ext.extend.onClick
h

evant
5 Nov 2010, 4:43 PM
Sounds like the error is happening the Google map code somewhere, not Ext.

At a glance, you never set the scope of the handler, so "this" will refer to the button object, which is probably not what you want.

Also, please try and format your code in some reasonable way, that's really difficult to read.