allow-pointer-lock
by Leo
HTML
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map"></div>
<div id="x"></div>
<div id="y"></div>
CSS
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 500px;
width: 500px;
}
#x {
height: 10px;
width: 10px;
background-color: red;
}
#y {
height: 10px;
width: 10px;
background-color: blue;
}
JavaScript
// This example creates a 2-pixel-wide red polyline showing the path of William
// Kingsford Smith's first trans-Pacific flight between Oakland, CA, and
// Brisbane, Australia.
function init() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: {lat: 0, lng: -180},
mapTypeId: google.maps.MapTypeId.TERRAIN
});
var flightPlanCoordinates = [
{lat: 37.772, lng: -122.214},
{lat: 21.291, lng: -157.821},
{lat: -18.142, lng: 178.431},
{lat: -27.467, lng: 153.027}
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
init();
var x = document.getElementById("x");
x.addEventListener("mouseover", function(){
var y = document.getElementById("y");
debugger;
y.requestPointerLock = y.requestPointerLock ||
y.mozRequestPointerLock ||
y.webkitRequestPointerLock;
// Ask the browser to lock the pointer
y.requestPointerLock();
});