Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

google maps in jsp

696705May 28 2009 — edited May 28 2009
Hi
I want to make my web page show map like here.

I have two files,

HTML:
<!DOCTYPE html PUBLIC "-//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&v=2&key=ABQIAAAAkvBRJltul61OdAADkYtUHxRi_j0U6kJrkFvY4-OX2XYmEAa76BR5i6ma_ABPri4uQ55PGlNna1o0mQ"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[

function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(0, 0), 1);
}
}

//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<di v id="map" style="width: 500px; height: 500px"></di v>
</body>
</html>


Which works fine, and

JSP:

<?xml version='1.0' encoding='windows-1250'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
xmlns:trh="http://myfaces.apache.org/trinidad/html">
<jsp:directive.page contentType="text/html;charset=windows-1250"/>
<f:view>
<af:document title="hello from component" >
<f:facet name="metaContainer">
<trh:script source="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAkvBRJltul61OdAADkYtUHxRi_j0U6kJrkFvY4-OX2XYmEAa76BR5i6ma_ABPri4uQ55PGlNna1o0mQ">

function load() {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(0, 0), 1);
}
} );

</trh:script>
</f:facet>
<af:form >
<af:commandButton text="show id" id="cmdbutton">
<af:clientListener method="load" type="action"/>
</af:commandButton>
</af:form>
<di v id="map" style="width: 400px; height: 400px"></di v>
</af:document>
</f:view>
</jsp:root>


JSP page loads fine, but when i click the button, maps shows for a second and disappears with browser error +'load' is undefined+, why this does not work?
I'm using JDeveloper 11g.

Edited by: Jakub Michalski on 2009-05-28 06:15
This post has been answered by Branislav Nemec on May 28 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2009
Added on May 28 2009
6 comments
1,682 views