Google Maps Component for Ext-JS

in Articles,Ext JS,How-To,Tutorials

Shea Frederick has created a user-defined extension to integrate Google Maps with ExtJS.

UPDATE: I’ve created a tutorial that uses the latest version of the extension and Ext-JS.

Ext.ns('Sample');
Sample.ExtGMap = function() {

	var el = 'ext-map';

	function _init() {

		new Ext.Panel({
			renderTo: el,
			layout: 'fit',
			height: 300,
			hideLabel: true,
			items: [
		        {
		        	xtype: 'gmappanel',
		        	gmapType: 'map',
		        	zoomLevel: 14,
		            setCenter: {
		        		lat: 40.782686,
		        		lng: -73.96524,
			            marker: {
		        			title: 'Central Park'
			            }
			        }
		        }
			]
		});

	}

	return {
		init: _init
	}

}();
Ext.onReady(Sample.ExtGMap.init, Sample.ExtGMap);

Configuration options:

It’s just as easy to create a Google map window that maps addresses and places markers at their locations (which could just as easily be nested in a layout instead).

A couple of the primary Google maps handlers and settings are setup as configuration options. For instance, ‘addControl’ allows adding of a standard Google map control (zoom, pan, etc) and the ‘zoomLevel’ sets a default zoom level for the map.

Geocoding can be used by substituting the lat/long configuration options with a ‘geoCodeAddr’ string.

The ’setCenter’ configuration allows the default center location of the map to be set, along with a marker. More markers can be added to the map using the ‘markers’ array.

Leave a Comment

{ 14 comments… read them below or add one }

Luis Cevallos August 2, 2010 at 22:10

Hi I really put your code for testing in my computer localhost but did not work please if you have and email for send you my code this is the messange in the firebug.

types[config.xtype || defaultType] is not a constructor
[Break On This Error] return config.render ? con...config.xtype || defaultType](config);

Thanks.

Have a nice day

Claude August 2, 2010 at 23:55

Luis, Make sure you’re loading all the necessary the libraries. Also, try working with the “-debug” versions while you learn.

Feel free to email me your code through the contact page.

Luis Cevallos August 3, 2010 at 02:06

Hi you are rigth I use all js and css but i have the next message:

Limit_Exceeded Preferencias
GStreetviewPanorama is not defined
[Break On This Error] this.gmap = new GStreetviewPanorama(this.body.dom);

Please help me I need to put Google map in extjs

Vera August 3, 2010 at 07:28

Hi,

I want to use Google maps component for ExtJS.

I’m trying use this code in my computer, but it doesn’t work, which libraries do I need?

i’m using :

Maybe… the problem is that i need to configure something?

Thanks!!!

Luis Cevallos August 3, 2010 at 08:47

Hi do you Know how to get de api of the ux map please I need to learn.
Thank you.
Have a nice day

Claude August 3, 2010 at 10:28

@Luis, @Vera: I know the map API and UX component have changed since this was posted. I will put a tutorial together in the next few days. Maybe that will help you guys.

Vera August 4, 2010 at 01:58

Thanks Claude, I’ll be waiting for your tutorial if I don’t get a solution for this.

Thanks again!!!

Claude August 5, 2010 at 01:26
Vera August 5, 2010 at 03:36

Claude, thank you very much for the tutorial. It’s very useful and easily to read.

The map API and UX component works perfectly.

I included these two libraries to my project:

and later added the ‘gmappanel’ to the panel and did a renderTo in the panel.

Thank you very much again!!!

Vera August 17, 2010 at 02:10

Hi again!

I have a new doubt about map API and UX component:

I want to load a certain location on the map, but later I would like to update the location with a new address or position(lat,long) when I click on a button.

How I can update the component or map? I tried to update the panel, but I didn’t get it.

Thank you very much.

Claude August 17, 2010 at 15:13

Take a look at the second part of that tutorial. It shows you how to expose public methods to allow manipulating the map after it has been rendered.

The point is to never create the component more than once.

Vera August 18, 2010 at 05:38

Hi,

First of all: “Thanks Claude”, I get to update the map with the new location. This location is with LatLng method. I’m trying now to use an address (like a string in geoCodeAddr: ‘address’), but I don’t get it.

I don’t find a method in google.maps to set the location with a string, doesn’t it exist?

Thank you.

Vera August 19, 2010 at 08:15

Hi,

I got to load a new location using an address(string) instead of using (lat,long). I used the geocoder method of google maps. It’s very useful.

Thanks.

Claude August 19, 2010 at 19:46

Excellent!

Previous post:

Next post: