This file contains hidden or 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
var map; | |
var mark; | |
var initialize = function() { | |
map = new google.maps.Map(document.getElementById('map-canvas'), {center:{lat:lat,lng:lng},zoom:12}); | |
mark = new google.maps.Marker({position:{lat:lat, lng:lng}, map:map}); | |
}; | |
window.initialize = initialize; |
This file contains hidden or 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
<script> | |
window.lat = 37.7850; | |
window.lng = -122.4383; | |
function getLocation() { | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(updatePosition); | |
} | |
return null; | |
}; | |
function updatePosition(position) { |
This file contains hidden or 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
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=YOUR_GOOGLE_MAPS_API_KEY&callback=initialize"></script> | |
</body> | |
</html> |
This file contains hidden or 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
setInterval(function() { | |
pubnub.publish({channel:pnChannel, message:circlePoint(new Date().getTime()/1000)}); | |
}, 500); | |
</script> |
This file contains hidden or 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
var pnChannel = "map-channel"; | |
var pubnub = new PubNub({ | |
publishKey: 'YOUR_PUB_KEY', | |
subscribeKey: 'YOUR_SUB_KEY' | |
}); | |
pubnub.subscribe({channels: [pnChannel]}); | |
pubnub.addListener({message:redraw}); |
This file contains hidden or 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
var redraw = function(payload) { | |
lat = payload.message.lat; | |
lng = payload.message.lng; | |
map.setCenter({lat:lat, lng:lng, alt:0}); | |
mark.setPosition({lat:lat, lng:lng, alt:0}); | |
}; |
This file contains hidden or 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
var map; | |
var mark; | |
var initialize = function() { | |
map = new google.maps.Map(document.getElementById('map-canvas'), {center:{lat:lat,lng:lng},zoom:12}); | |
mark = new google.maps.Marker({position:{lat:lat, lng:lng}, map:map}); | |
}; | |
window.initialize = initialize; |
This file contains hidden or 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
<script> | |
window.lat = 37.7850; | |
window.lng = -122.4383; | |
function circlePoint(time) { | |
var radius = 0.01; | |
var x = Math.cos(time) * radius; | |
var y = Math.sin(time) * radius; | |
return {lat:window.lat + y, lng:window.lng + x}; | |
}; |
This file contains hidden or 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
<div class="container"> | |
<h1>PubNub Google Maps Tutorial - Live Map Marker</h1> | |
<div id="map-canvas" style="width:600px;height:400px"></div> | |
</div> |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>Google Maps Tutorial</title> | |
<script src="https://cdn.pubnub.com/sdk/javascript/pubnub.4.19.0.min.js"></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" /> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" /> | |
</head> | |
<body> |