PDA

View Full Version : Maps in Extjs4



Sabareesh
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



chrome://firebug/content/blank.gif


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



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

{
xtype: 'gmappanel',
title:'Maps',
id :'gmap',
listeners: {
afterrender : function()
{
Ext.get('gmap').load({
url: 'graph',
scripts: true,
params:{
action :'doGetGoogleMap' // this returns the jsp map.jsp
}

});
}
}

}

this is my map.jsp

<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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"
type="text/javascript"></script>
<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);
map.setUIToDefault();
}
}

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

can anyone help me , wat iam doing wrong

thanks

Sabareesh
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 .

Thanks.

scottmartin
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?

Scott.

Sabareesh
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 .

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

Scott.

Sabareesh
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.