Skip to content

Instantly share code, notes, and snippets.

@ChrisWeymann ChrisWeymann/DynMap.html Secret
Created Dec 15, 2015

Embed
What would you like to do?
<!DOCTYPE html>
<html>
<head>
<title>OpenSim Region Map</title>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 0, lng: 0},
zoom: 1,
streetViewControl: false,
mapTypeControlOptions: {
mapTypeIds: ['moon']
}
});
var moonMapType = new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
var normalizedCoord = calcPos(coord.x, coord.y);
if (!normalizedCoord) {
return null;
}
var bound = Math.pow(2, zoom);
return 'http://grid.chris-weymann.de:8002/map-1-' +
+ normalizedCoord.x + '-' +
normalizedCoord.y + '-objects.jpg';
},
tileSize: new google.maps.Size(64, 64),
maxZoom: 2,
minZoom: 0,
radius: 1738000,
name: 'OpenSim'
});
map.mapTypes.set('moon', moonMapType);
map.setMapTypeId('moon');
}
function calcPos(posX, posY)
{
var offsetX = 7750;
var offsetY = 7750;
return {x: (offsetX + posX), y: (offsetY - posY)}
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=***************************&signed_in=true&callback=initMap"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.