View Full Version : Maps in Extjs4

30 May 2012, 11:50 PM
I am trying to use google maps in my application . But I am facing the following problem

"GMap2 is not defined


this.gmap = new GMap2(this.body.dom);"

I have my GMapPanel.js included and I am having the following code

xtype: 'gmappanel',
id :'gmap',
listeners: {
afterrender : function()
url: 'graph',
scripts: true,
action :'doGetGoogleMap' // this returns the jsp map.jsp



this is my map.jsp

<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Maps JavaScript API Example</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=MyApiKey&sensor=true"
<script type="text/javascript">

function initialize() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

<body onload="initialize()" onunload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 300px"></div>

can anyone help me , wat iam doing wrong


31 May 2012, 2:29 AM
If i call the method doGetGoogleMap() from my address bar in IE such as
http://localhost:8080/Maps/home?action=doGetGoogleMap() , the map is showing
the same thing is not working with firefox .

Can anyone tell why it is so .


31 May 2012, 10:41 AM
Create a simply app that includes what is needed (GMapPanel, etc) and then create a button to open a map in a window .. does this work?


31 May 2012, 10:27 PM
Hi scottmartin ,

Thanks , I tried it as u said , and was working fine in IE , but not in firefox, so i checked my Internet options and found the problem , and it is working fine in both the browsers and also integrated in my application.

Is there any example on how to take markers from server side ?

Thanks .

1 Jun 2012, 4:56 AM
You should be able to check the Google maps API for the proper tags.


4 Jun 2012, 4:49 AM
Thanks scott .

I included markers in my map , which i have hard coded for now. Once i form my JSON from server side i will take markers from that .

Also I have included labels which appear above the marker , which i think is not a function of google map API V3 . I went through the API , but i couldn't find any thing related to this .

I do know why they missed out this functionality . It might be a small one , but most users like the labels above the markers.

I hope they include this functionality in upcoming versions.