Created
November 15, 2013 20:33
-
-
Save jamesfalkner/7491097 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## AJAXification with well-formed JSON result construction | |
## AJAXification with AUI and JSON parameters | |
#set ($pns = $request.portlet-namespace) | |
<body> | |
<link href="//code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" /> | |
<script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script> | |
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js"></script> | |
<div id="${pns}map" style="height: 400px; margin-bottom: 1.5em; width: 100%;"><!-- --></div> | |
<script type="text/javascript"> | |
var names=["James Falkner", "Some Girl", "Some Guy"]; | |
var emails = ["[email protected]", "[email protected]", "[email protected]"]; | |
var count = 0; | |
var ${pns}googleMap = new google.maps.Map( | |
document.getElementById("${pns}map"), | |
{ | |
center: new google.maps.LatLng(37.794044, -122.395691), | |
mapTypeControl: false, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, | |
navigationControl: false, | |
scaleControl: false, | |
streetViewControl: false, | |
zoom: 17 | |
} | |
); | |
Liferay.on( | |
'locationUpdate', | |
function(event) { | |
var idx = count++; | |
if (idx >= emails.length) { | |
count = 0; | |
idx = 0; | |
} | |
var hash = CryptoJS.MD5(emails[idx]); | |
var name = names[idx]; | |
var infoWindow = new google.maps.InfoWindow( | |
{ | |
content: '<p><img src="http://gravatar.com/avatar/' + hash + '"></p><code>' + name + '</code>', | |
position: new google.maps.LatLng(event.position.lat, event.position.lng) | |
} | |
); | |
infoWindow.setOptions( | |
{ | |
disableAutoPan: false | |
} | |
); | |
infoWindow.open(${pns}googleMap); | |
setTimeout( | |
function() { | |
infoWindow.close(); | |
}, | |
15000 | |
); | |
} | |
); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment