Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
pawan chauhan
How to use HTML tags in liferay
October 24, 2012 11:36 PM
Answer

pawan chauhan

Rank: Junior Member

Posts: 75

Join Date: October 8, 2012

Recent Posts

Hi all,
I have been trying to use google maps api in my liferay application.
using the following code snippet i can do so but the problem is that i cant change this code to format that can be put in "view.jsp" of liferay.
please help me.

code snippet:


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxxxxxxxxxxxx&sensor=true">
</script>
<script type="text/javascript">
function initialize()
{
var mapOptions = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
James Falkner
RE: How to use HTML tags in liferay
October 19, 2012 10:53 AM
Answer

James Falkner

Community Moderator

Rank: Liferay Legend

Posts: 1406

Join Date: September 17, 2010

Recent Posts

pawan chauhan:
Hi all,
I have been trying to use google maps api in my liferay application.
using the following code snippet i can do so but the problem is that i cant change this code to format that can be put in "view.jsp" of liferay.
please help me.



Is that your own Google API key? You might not want to post that in the forum, but even better you might want to upgrade to the Google Maps API Version 3 which no longer requires an API key.

What errors do you get?
pawan chauhan
RE: How to use HTML tags in liferay
October 24, 2012 10:52 PM
Answer

pawan chauhan

Rank: Junior Member

Posts: 75

Join Date: October 8, 2012

Recent Posts

Hi james,
When i put that code snippet in view.jsp, nothing gets displayed on the portal.
James Falkner
RE: How to use HTML tags in liferay
October 30, 2012 2:51 PM
Answer

James Falkner

Community Moderator

Rank: Liferay Legend

Posts: 1406

Join Date: September 17, 2010

Recent Posts

pawan chauhan:
Hi james,
When i put that code snippet in view.jsp, nothing gets displayed on the portal.



Try this for view.jsp:

 1<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
 2
 3<portlet:defineObjects />
 4
 5<script type="text/javascript"
 6 src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
 7</script>
 8<script type="text/javascript">
 9      var map;
10      function initialize() {
11console.log("init");
12        var mapOptions = {
13          zoom: 8,
14          center: new google.maps.LatLng(-34.397, 150.644),
15          mapTypeId: google.maps.MapTypeId.ROADMAP
16        };
17        map = new google.maps.Map(document.getElementById('map_canvas'),
18            mapOptions);
19      }
20
21      google.maps.event.addDomListener(window, 'load', initialize);
22</script>
23</head>
24<div id="map_canvas" style="width:500px; height:500px"></div>
Milan Palian
RE: How to use HTML tags in liferay
September 24, 2013 11:53 AM
Answer

Milan Palian

Rank: Junior Member

Posts: 43

Join Date: December 10, 2009

Recent Posts

James,

It is really nice to have an example like this that works immediately using copy-paste, instead of having to fill in the gaps.

Thanks,
Milan