View Full Version : Adding markers to gmappanel from MVC controller - getMap method does not exist

12 May 2013, 6:44 PM

In my application I have a set of buttons for locations and then a gmappanel. I would like to add the a marker to the map that corresponds to the button when clicked.

I've looked through the demo files and searched online and it seems like every instance of adding a marker starts with getting the gmappanel component and then setting a variable to the result of the method "getMap()" for the gmappanel component. When I try to do this the method doesn't show and when I search through the documentation for gmappanel I don't see the method listed. Is this not the proper way to get the map from the gmappanel component?

My map is defined like this:

xtype: 'container',
id : 'mapContainer',
autoShow: true,
layout: {type: 'fit', pack: 'center', align: 'center'},
title: 'GMap Window',
closeAction: 'hide',
width: '100%',
border: false,
x: 40,
y: 60,
items: {
xtype: 'gmappanel',
id: 'eventMap',
center: {
geoCodeAddr: '2414 Menard Street, St. Louis, MO'

So the process I need to build in my controller is to:

Get the gmappanel component
Somehow, get the map
Create a marker object that contains the latitude and longitude values for the button's location
Apply that marker object to the map via the addMarker method

14 May 2013, 7:22 AM
Sounds like maybe a scoping issue or the component wasn't resolved correctly. Don't see code for where the getMap method is called.

19 May 2013, 5:36 AM
Ah gotcha.

I haven't built the method in my controller that calls the getMap method yet. I was trying it out in the javascript console first. I've been using the following javascript commands just to see if it would work:

var mapComponent = Ext.getCmp('eventMap');
var map = mapComponent.getMap();

The "mapComponent.getMap()" just says that the method does not exist for the object (which I can see as it does not show in the autocomplete list as I'm typing getMap).

I thought it could be a scope issue so I looked to through the extjs documentation both in my local sdk and the sencha docs subdirectory and I cannot find a mention of the method getMap anywhere. Is there a different approach and method I'm supposed to use?

19 May 2013, 6:12 PM
I figured it out. The methods that I was looking for don't exist in sencha, they're google's maps api methods.


I'm following the examples that google outlines here and they're working:


Thanks for reaching out to help.