I have created a custom map using the Google Maps API v3. It's a rectangular map of a fictional world, not of anything in the real world.
I have been reading articles on how to use Projections in custom Google Maps. I need to use a Projection because placing Markers and Regions using Projections, they do not repeat horizontally. Anyways, I pulled the following code from a tutorial:
var tilesize = 256;
function MyProjection(){}
MyProjection.prototype.fromLatLngToPoint = function(latLng)
{
var x = latLng.lng() * tileSize;
var y = latLng.lat() * tileSize;
return new google.maps.Point(x, y);
};
MyProjection.prototype.fromPointToLatLng = function(point)
{
var lng = point.x * (1.0 / tileSize);
var lat = point.y * (1.0 / tileSize);
return new google.maps.LatLng(lat, lng);
};
function LatLngToPixels(latLng)
{
var pnt = MyProjection.prototype.fromLatLngToPoint(latLng);
return [pnt.x * 8, pnt.y * 8];
}
function PixelsToLatLng(pxs)
{
var pnt = {x: pxs[0] / 8, y: pxs[1] / 8};
return MyProjection.prototype.fromPointToLatLng(pnt);
}
I've applied it to my map and it seems to work. However, I'm trying to figure out how to alter the scale of the projection. When I place a marker like this:
new google.maps.Marker(
{
map: map,
position: new google.maps.LatLng(0, 0)
});
The marker is placed at the top left corner of the map. If I do this:
new google.maps.Marker(
{
map: map,
position: new google.maps.LatLng(1, 1)
});
the marker is placed at the bottom right.
So I basically have a minimum longitude and latitude of 0 and a max of 1 to work with. How can I alter the above functions so that the scale is a bit more managable? Like 0 to 90 or 0 to 180? Something that makes a bit more sense in terms of real-world longitude and latitude coordinates? Or is that not possible with Projections? I'm a bit confused by the idea of projections and what exactly their ultimate purpose is so maybe I'm missing the point...