Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
pawan chauhan
How to use HTML tags in liferay
24 ottobre 2012 23.36
Risposta

pawan chauhan

Punteggio: Junior Member

Messaggi: 75

Data di Iscrizione: 8 ottobre 2012

Messaggi recenti

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
19 ottobre 2012 10.53
Risposta

James Falkner

Community Moderator

Punteggio: Liferay Legend

Messaggi: 1406

Data di Iscrizione: 17 settembre 2010

Messaggi recenti

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
24 ottobre 2012 22.52
Risposta

pawan chauhan

Punteggio: Junior Member

Messaggi: 75

Data di Iscrizione: 8 ottobre 2012

Messaggi recenti

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
30 ottobre 2012 14.51
Risposta

James Falkner

Community Moderator

Punteggio: Liferay Legend

Messaggi: 1406

Data di Iscrizione: 17 settembre 2010

Messaggi recenti

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
24 settembre 2013 11.53
Risposta

Milan Palian

Punteggio: Junior Member

Messaggi: 43

Data di Iscrizione: 10 dicembre 2009

Messaggi recenti

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