Mercurial > hg > batmud > gmap2
view js/map.js @ 16:ec4f7f015123 gmap2
Cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 08 Jan 2011 12:48:32 +0200 |
parents | bc9c1029266a |
children |
line wrap: on
line source
// $Id: map.js 2404 2009-12-24 20:01:32Z jeskko $ var map = new GMap2(document.getElementById("map"),{draggableCursor: 'crosshair', draggingCursor: 'pointer'}); map.enableContinuousZoom(); map.enableScrollWheelZoom(); map.addControl(new GLargeMapControl3D()); var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, "Map data by BAT ry, Ooga, Ggr, Slobber and Jeskko"); var cc = new GCopyrightCollection('BatMUD'); cc.addCopyright(copyright); var tl = [new GTileLayer(cc, 2, 10), new GTileLayer(cc, 2, 10)]; tl[0].getTileUrl = function(a,b) { return "/map/tiles/"+(b)+"/"+a.y+"/"+a.x+".png"; } tl[1].getTileUrl = function(a,b) { return "/map/overlay.php?x="+a.x+"&y="+a.y+"&zoom="+(b); } var custommap = new GMapType(tl, new GMercatorProjection(12),"BatMud", {errorMessage:"No data available"}); map.addMapType(custommap); var proj=map.getCurrentMapType().getProjection(); map.setCenter(proj.fromPixelToLatLng(new GPoint(8556,8664),6),3,custommap); function checkCoords(cx, cy, cxmin, cymin, cxmax, cymax, cname) { if (cx > cxmin && cx < cxmax && cy > cymin && cy < cymax) { return {x: cx + cxmin, y: cy + cymin, name: cname}; } else { return null; } } var continents = [ // "Name" x0, y0, x1, y1 ["Laenor", 0, 0, 829, 783], ["Furnachia", 1210, 1154, 1653, 1655], ["Rothikgen", 1310, -1256, 1792, -774], ["Lucentium", -635, 2344, 68, 2847], ["Desolathya", -1211, 819, -669, 1352], ["Renardy", 2066, -912, 2238, -825], ]; google.maps.Event.addListener(map, "mousemove", function(point) { var p = proj.fromLatLngToPixel(point,7); tx = Math.round((p.x-16383)/2)-1; ty = Math.round((p.y-16383)/2)-1; xx = tx; yy = ty; cont = "Deep Sea"; for (i = 0; i < continents.length; i++) { var c = continents[i]; if (tx > c[1] && tx < c[3] && ty > c[2] && ty < c[4]) { cont = c[0]; xx = tx - c[1]; yy = ty - c[2]; break; } } document.getElementById("xcoord").innerHTML = xx; document.getElementById("ycoord").innerHTML = yy; document.getElementById("continent").innerHTML = cont; });