Hello,
I just can't seem to figure out how to set up my own custom map and am
starting to get desperate for help.
I am trying to make a custom google map interface for a computer game
world.
I have organized my tiles into folders like this:
tiles\zoomLevel\x\y.jpg
so my function to get the tiles goes like:
function CustomGetTileUrl(a,b){
return "tiles/" + b + "/" + a.x + "/" + a.y + ".jpg";
}
now, the game world has its own coordinate system with boundaries of
-40.0 S, -20.0 W as south west corner and 0.0 N, 20.0 E as north east
corner.
So I did my copyright thing like:
var map = new GMap2(document.getElementById("map"));
map.enableScrollWheelZoom();
var copyCollection = new GCopyrightCollection('v');
var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng
(-40.0,-20.0), new GLatLng(0.00,20.0)), 0, "test");
copyCollection.addCopyright(copyright);
I setup my tile layers:
var tilelayers = new Array();
tilelayers[0] = new GTileLayer(copyCollection, 2, 6 );
tilelayers[0].getTileUrl = CustomGetTileUrl
tilelayers[0].getOpacity = function () {return 1.00;};
tilelayers[0].isPng = function() {return true;};
GMap options:
var GMapTypeOptions = new Object();
GMapTypeOptions.minResolution = 2;
GMapTypeOptions.maxResolution = 6;
GMapTypeOptions.errorMessage = "No map data available";
custom map:
var custommap = new GMapType(tilelayers, new GMercatorProjection(22),
"test", GMapTypeOptions);
custommap.getTextColor = function() { return "#000000"; };
map.addMapType(custommap);
set center:
map.setCenter( new GLatLng(-20.0,0.00), 2, custommap );
So I did all this and my map displays perfectly. It draws the map fine
and I can zoom in 5 levels like I setup tiles for. Great!
But now I have two problems...
One is my map redraws itself (repeats) infinitely to the west and
east. It just goes on forever. But for north and south it displays
blank tiles if you got beyond the map boundary. I want this behavior
for east and west - how?
And much more urgent situation is I cannot add my map markers where I
expect them.
For example If I plot something which exists on the bottom left corner
of the game world, whose coordinates in game are -40.0S, -20.0W, so
doing:
var marker = new GMarker(new GLatLng(-40.0, -20.0), icon);
map.addOverlay(marker);
It ends up showing up just a little below the center of my map,
totally unexpected.
After playing around with the numbers it seems I have to enter new
GLatLng(-85.0, -180.0) to nail the marker at the bottom left of my map
but this does not match the game's coordinate system.
Is there any way I can get these coordinates to match my in-game
coordinates so I dont have to do any kind of mathematical conversion?
I dont even know what kind of conversion I'd need to do here anyway...
Any help would be GREATLY appreciated!!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---