Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
pawan chauhan
How to use HTML tags in liferay
24. Oktober 2012 23:36
Antwort

pawan chauhan

Rang: Junior Member

Nachrichten: 75

Eintrittsdatum: 8. Oktober 2012

Neue Beiträge

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. Oktober 2012 10:53
Antwort

James Falkner

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1325

Eintrittsdatum: 17. September 2010

Neue Beiträge

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. Oktober 2012 22:52
Antwort

pawan chauhan

Rang: Junior Member

Nachrichten: 75

Eintrittsdatum: 8. Oktober 2012

Neue Beiträge

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. Oktober 2012 14:51
Antwort

James Falkner

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1325

Eintrittsdatum: 17. September 2010

Neue Beiträge

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. September 2013 11:53
Antwort

Milan Palian

Rang: Junior Member

Nachrichten: 43

Eintrittsdatum: 10. Dezember 2009

Neue Beiträge

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