notes/Basic Google Map Move Marker-y524LsxH.html
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple icons</title>
<link href="https://developers.google.com/maps/documentation/javascript/examples/default.css" rel="stylesheet">
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script>
x=26.0906973;
y=-81.732371;
function initialize() {
var mapOptions = {
zoom: 15,
center: new google.maps.LatLng(x,y),
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
var image = 'http://www.apponic.com/data/softimg/mac/audio/audio-editors/tux-guitar-79268-icon.jpeg';
var myLatLng = new google.maps.LatLng(x,y);
marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image
});
moveMarker( map, marker );
}
function moveMarker( map, marker ) {
//delayed so you can see it move
setInterval( function(){
x+=0.0001010;
y-=0.0001010;
marker.setPosition( new google.maps.LatLng( x, y ) );
map.panTo( new google.maps.LatLng( x, y ) );
}, 500 );
};
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
<button>Click me</button>
</body>
</html>
syntax highlighted by Code2HTML, v. 0.9.1