mandelmapper/web.go
Steven Polley 884f2f0f80
All checks were successful
continuous-integration/drone/push Build is passing
update web API key
2021-06-11 16:40:32 -06:00

75 lines
1.8 KiB
Go

package main
import (
"fmt"
"net/http"
)
func init() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
w.Header().Set("Location", "/")
w.WriteHeader(http.StatusMovedPermanently)
return
}
r.ParseForm()
fmt.Fprintf(w, `<!DOCTYPE html>
<html>
<head>
<title>MandelMapper</title>
<meta property="og:url" content="https://mandelmap.deadbeef.codes/" />
<meta property="og:type" content="website" />
<meta property="og:title" content="Mandelbrot Mapper">
<meta property="og:description" content="A Google maps front end to a distributed real-time fractal renderer">
<meta property="og:image" content="https://deadbeef.codes/img/mandelbrot.png" />
<meta property="og:site_name" content="deadbeef.codes">
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDJJV_-Q2wIBlzYVzfIbZTapl-8tMoYxw8"></script>
<script>
var mandelbrotTypeOptions = {
getTileUrl: function(coord, zoom) {
return '/mandelbrot/' + zoom + '/' + coord.x + '/' + coord.y + '.png?label=%s';
},
tileSize: new google.maps.Size(128, 128),
maxZoom: (1<<16),
minZoom: 1,
name: '0xdeadbeef Mandel Mapper'
};
var mandelbrotMapType = new google.maps.ImageMapType(mandelbrotTypeOptions);
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(0, 0),
zoom: 1,
streetViewControl: false,
mapTypeControlOptions: {
mapTypeIds: ['mandelbrot']
}
};
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
map.mapTypes.set('mandelbrot', mandelbrotMapType);
map.setMapTypeId('mandelbrot');
}
</script>
<style>
#map_canvas {
position: absolute !important;
left: 0 !important;
right: 0 !important;
top: 0 !important;
bottom: 0 !important;
}
</style>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>`, r.FormValue("label"))
})
}