Skip to content

Instantly share code, notes, and snippets.

@mapcentia
Last active September 6, 2017 21:25
Show Gist options
  • Save mapcentia/3566f730e6f9510c417f1c85613c4d3a to your computer and use it in GitHub Desktop.
Save mapcentia/3566f730e6f9510c417f1c85613c4d3a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Google and GC2</title>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<script src="https://maps.google.com/maps/api/js?sensor=false"></script>
<script>
function init() {
var opts = {
streetViewControl: false,
tilt: 0,
center: new google.maps.LatLng(0, 0),
zoom: 3
};
var map = new google.maps.Map(document.getElementById('map'), opts);
// Add tile layer "public.test1"
var layerOptions = {
getTileUrl: function(coord, zoom) {
return "https://gc2.mapcentia.com/mapcache/mydb/gmaps/public.test1/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
},
tileSize: new google.maps.Size(256,256) // or whatever
};
map.overlayMapTypes.insertAt(0, new google.maps.ImageMapType(layerOptions));
// Add vector layer public.test2 form SQL API.
// MAY CAUSE CROSS BROWSER ISSUE
// GC2 server must have domain white listed or use * (the latter is the case on gc2.mapcentia.com)
map.data.loadGeoJson('https://gc2.mapcentia.com/api/v1/sql/mydb?q=SELECT * FROM public.test2&srs=4326');
map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
}
</script>
<style>
html, body, #map { width:100%; height:100%; margin:0; padding:0; }
</style>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment