I have a .NET application that typically uses the standard Google Maps JavaScript API V2. Within this application I am using a GTileLayerOverlay to add my own custom dynamic tile layer.
function addJourneyLineOverlay(assetId, startDate, finishDate) {
var path = "http://<%= Request.Url.Host %>";
if ("<%= Request.Url.Port %>" != 80) {
path += ":<%= Request.Url.Port %>";
}
path += "/Private/polyLineTileLayer/Tile.aspx";
var myCopyright = new GCopyrightCollection("(c) ");
myCopyright.addCopyright(new GCopyright('Demo', new GLatLngBounds(new GLatLng(-20, 130), new GLatLng(-30, 155)), 0, '@2012 IMT Pty Ltd'));
var journeyPathLayer = new GTileLayer(myCopyright);
journeyPathLayer.getTileUrl = function (tile, zoom) {
return path + '?zoom=' + zoom +
'&x=' + tile.x +
'&y=' + tile.y +
'&assetId=' + assetId +
'&startDate=' + startDate +
'&finishDate=' + finishDate;
};
journeyPathLayer.isPng = function () {
return true;
};
journeyPathLayer.getOpacity = function () {
return 1.0;
};
journeyPathOverlay = new GTileLayerOverlay(journeyPathLayer);
map.addOverlay(journeyPathOverlay);
}
This overlay requests it tiles from an aspx page that gets some points from a database, determines if the points are in the tile and then returns an image with the points on it. I developed it based on the same pattern as Gheat.net. And I am also using the Gmap.Net library for its Mercator projection, for when I need to work out which points should be in which tiles.
This works really well when I am using the standard Google maps API. However, recently I have to integrate my application with our clients Google Earth Enterprise server. This means that I am now getting my map imagery and API from our clients server and not from Google proper. This has caused a problem with my overlay.
My overlay is not longer position where it should be relative to the map location. They are appearing a bit lower that where they should be.
Using firebug I examined the request for my tile layer and found out that the tile X and Y where different than what I was expecting.
At zoom level 12, using Google maps a particular LatLng location is in tile X-3392, Y-2312. But in Google Earth the same location at the same zoom level is in tile X-3392, Y-2305. that's a 7 tile difference in the Y axis.
What can account for this difference? Does Google Earth use a difference projection, if so is there a convenient .net library for it?