test_objective_
by Wolf
HTML
<!DOCTYPE html>
<html>
<head>
<title>Image map types</title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function MyProjection(){
this.width =256;
this.height =256;
}
MyProjection.prototype.fromLatLngToPoint = function(latLng)
{
var x = latLng.lng() * () * this.width;
var y = latLng.lat() * this.height;
return new google.maps.Point(x, y);
};
MyProjection.prototype.fromPointToLatLng = function(point)
{
var lng = point.x * (1.0 / this.width);
var lat = point.y * (1.0 / this.height);
return new google.maps.LatLng(lat, lng);
};
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 = getNormalizedCoord(coord, zoom);
if (!normalizedCoord) {
return null;
}
var bound = Math.pow(2, zoom);
return 'http://climbmaps.com/ph/441' +'/' + zoom + '/' + normalizedCoord.x + '/' + normalizedCoord.y + '.jpg';
},
tileSize: new google.maps.Size(256, 256),
maxZoom: 9,
minZoom: 0,
radius: 1738000,
name: 'Moon'
});
moonMapType.projection = new MyProjection();
map.mapTypes.set('moon', moonMapType);
...