annotate map.js @ 265:e908103cdcd8 gmap2

Change how map initialization arguments are handled.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 Apr 2014 20:52:11 +0300
parents 7e57e5577425
children b50a7ab76548
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
1 // $Id: map.js 2404 2009-12-24 20:01:32Z jeskko $
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
2
250
ee5492ccba8e Add configurable base URL.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
3 var pmapBaseURL;
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
4 var pmap;
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
5 var pmapCanvas;
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
6
170
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
7 var pmapTileSize = 256;
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
8 var pmapTileOrig = pmapTileSize / 2.0;
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
9 var pmapTilePxPerDeg = pmapTileSize / 360.0;
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
10 var pmapTilePxPerRad = pmapTileSize / (2.0 * Math.PI);
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
11
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
12
171
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
13 function pmapMinMax(vval, vmin, vmax)
170
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
14 {
171
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
15 return Math.min(Math.max(vval, vmin), vmax);
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
16 }
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
17
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
18
172
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
19 function pmapLatLngToMapCoords(latLng, zoom)
171
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
20 {
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
21 msiny = pmapMinMax(Math.sin((latLng.lat() * Math.PI) / 180.0), -0.9999, 0.9999);
170
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
22
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
23 px = latLng.lng() * pmapTilePxPerDeg;
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
24 py = 0.5 * Math.log((1 + msiny) / (1 - msiny)) * - pmapTilePxPerRad;
171
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
25
172
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
26 pz = 1 << zoom;
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
27 return new google.maps.Point(px * pz, py * pz);
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
28 }
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
29
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
30
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
31 function pmapMapCoordsToLatLng(point, zoom)
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
32 {
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
33 pz = 1 << zoom;
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
34 px = point.x / pz;
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
35 py = point.y / pz;
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
36
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
37 lng = (px - pmapTileOrig) / pmapTilePxPerDeg;
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
38 latRadians = (py - pmapTileOrig) / - pmapTilePxPerRad;
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
39
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
40 //lat = radiansToDegrees(2 * Math.atan(Math.exp(latRadians)) - Math.PI / 2);
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
41 //lat = (2 * Math.atan(Math.exp(latRadians)) - Math.PI / 2) / (Math.PI / 180);
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
42
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
43 lat = (360 * Math.atan(Math.exp(latRadians))) / Math.PI - 90;
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
44
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
45 return new google.maps.LatLng(lat, lng);
170
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
46 }
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
47
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
48
166
21cf84dcae73 Move code.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
49 function CanvasProjectionOverlay() {}
21cf84dcae73 Move code.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
50 CanvasProjectionOverlay.prototype = new google.maps.OverlayView();
21cf84dcae73 Move code.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
51 CanvasProjectionOverlay.prototype.constructor = CanvasProjectionOverlay;
21cf84dcae73 Move code.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
52 CanvasProjectionOverlay.prototype.onAdd = function(){};
21cf84dcae73 Move code.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
53 CanvasProjectionOverlay.prototype.draw = function(){};
21cf84dcae73 Move code.
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
54 CanvasProjectionOverlay.prototype.onRemove = function(){};
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
55
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
56
262
254343316a90 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 250
diff changeset
57 function pmapInitializeMap(args)
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
58 {
171
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
59 // Initialize custom imagemap with our tiles
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
60 var pmapBatMap = new google.maps.ImageMapType(
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
61 {
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
62 getTileUrl: function(coord, zoom)
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
63 {
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
64 return "tiles/"+ zoom +"/"+ coord.y +"/"+ coord.x +".png";
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
65 },
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
66
171
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
67 tileSize: new google.maps.Size(pmapTileSize, pmapTileSize),
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
68 maxZoom: 10,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
69 minZoom: 3,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
70 radius: 1738000,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
71 name: 'BatMap'
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
72 });
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
73
171
b874aae3e75f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
74 // Create map controller object
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
75 pmap = new google.maps.Map(document.getElementById("map"),
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
76 {
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
77 zoom: 3,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
78 center: new google.maps.LatLng(-15, 10),
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
79
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
80 streetViewControl: false,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
81 draggableCursor: 'crosshair',
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
82 draggingCursor: 'pointer',
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
83 mapTypeControl: false,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
84 scaleControl: false,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
85 rotateControl: false,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
86 overviewMapControl: false,
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
87 });
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
88
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
89 pmap.mapTypes.set('BatMap', pmapBatMap);
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
90 pmap.setMapTypeId('BatMap');
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
91
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
92 pmapCanvas = new CanvasProjectionOverlay();
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
93 pmapCanvas.setMap(pmap);
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
94
170
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
95 google.maps.event.addListener(pmap, "mousemove", pmapCoordinateListener);
265
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
96
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
97 if (typeof(args) == "object")
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
98 {
265
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
99 if ("zoom" in args && "x" in args && "y" in args)
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
100 {
265
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
101 google.maps.event.addDomListener(pmap, "foobar", function()
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
102 {
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
103 pmap.setZoom(args.zoom);
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
104 pmap.panTo(pmapMapCoordsToLatLng(new google.maps.Point(args.x, args.y), 6));
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
105 var tgtMarker = pmapGetMarkerIndexByCoords(args.x, args.y);
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
106 if (tgtMarker)
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
107 pmapMyClick(tgtMarker);
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
108 });
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
109 }
e908103cdcd8 Change how map initialization arguments are handled.
Matti Hamalainen <ccr@tnsp.org>
parents: 263
diff changeset
110 }
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
111 }
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
112
224
85ee47035acf Open marker info window if specified coordinates hit it exactly.
Matti Hamalainen <ccr@tnsp.org>
parents: 200
diff changeset
113 pmapInitializeNav();
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
114 pmapInitializeIcons();
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
115 pmapInitializeMarkers();
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
116 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
117
93
2324a519ebec Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 92
diff changeset
118
151
13e75e9e732a Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
119 //
152
095754c6b332 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 151
diff changeset
120 // Listener for updating coordinates display
151
13e75e9e732a Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
121 //
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
122 function pmapCoordinateListener(point)
93
2324a519ebec Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 92
diff changeset
123 {
228
2be6060df6cc Use global offsets.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
124 // Round the coordinates so that we hit the pointed square more accurately
172
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
125 var p = pmapLatLngToMapCoords(point.latLng, 7);
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
126 var tx = Math.round((p.x + 1) / 2.0);
c62f0cf2bf16 It almost works \:D\
Matti Hamalainen <ccr@tnsp.org>
parents: 171
diff changeset
127 var ty = Math.round((p.y + 1) / 2.0);
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
128
200
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
129 var cx, cy;
161
074b6936ec4f "Kind of works", but not really. Almost nothing works. And even that
Matti Hamalainen <ccr@tnsp.org>
parents: 157
diff changeset
130 var cont = "Deep Sea";
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
131
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
132 for (i = 0; i < pmapContinents.length; i++)
93
2324a519ebec Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 92
diff changeset
133 {
157
fadfd0e0a312 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 153
diff changeset
134 var c = pmapContinents[i];
93
2324a519ebec Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 92
diff changeset
135 if (c != null && tx > c[1] && tx < c[3] && ty > c[2] && ty < c[4])
2324a519ebec Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 92
diff changeset
136 {
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
137 cont = c[0];
170
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
138 cx = tx - c[1];
fb98e644b80c Fix coordinates display.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
139 cy = ty - c[2];
91
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
140 break;
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
141 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
142 }
e4a37528f1a7 Convert line ends via dos2unix.
Matti Hamalainen <ccr@tnsp.org>
parents: 76
diff changeset
143
230
c5a06121ed95 Adjust coordinates.
Matti Hamalainen <ccr@tnsp.org>
parents: 228
diff changeset
144 tx += pmapWorld.ox - 1;
c5a06121ed95 Adjust coordinates.
Matti Hamalainen <ccr@tnsp.org>
parents: 228
diff changeset
145 ty += pmapWorld.oy - 1;
200
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
146
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
147 var str = "Cursor: "+
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
148 "Global X: <span class=\"coord\">"+ tx +"</span>, Y: <span class=\"coord\">"+ ty +"</span>, "+
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
149 "Continent: <span class=\"continent\">"+ cont +"</span> ";
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
150
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
151 if (cx >= 0 && cy >= 0)
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
152 str += "[ Local X: <span class=\"coord\">"+ cx +"</span>, Y: <span class=\"coord\">"+ cy +"</span> ]";
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
153
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
154 document.getElementById("footercontent").innerHTML = str;
153
a7f43ddd1c5e Functionalize.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
155 }
200
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
156
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
157
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
158 function pmapMakeLink()
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
159 {
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
160 if (pmap)
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
161 {
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
162 var p = pmapLatLngToMapCoords(pmap.getCenter(), 6);
235
0e6fa3f5684d Adjust generated link coordinates so that they match what we desire.
Matti Hamalainen <ccr@tnsp.org>
parents: 230
diff changeset
163 var tx = Math.round(p.x) + pmapWorld.ox - 1;
228
2be6060df6cc Use global offsets.
Matti Hamalainen <ccr@tnsp.org>
parents: 224
diff changeset
164 var ty = Math.round(p.y) + pmapWorld.oy;
200
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
165
250
ee5492ccba8e Add configurable base URL.
Matti Hamalainen <ccr@tnsp.org>
parents: 235
diff changeset
166 str = pmapBaseURL +"?x="+ tx +"&y="+ ty +"&zoom="+ pmap.getZoom();
200
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
167
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
168 window.prompt("Copy to clipboard: Ctrl+C, Enter", str);
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
169 }
f5aa704b1ddf Add "Make a link" feature.
Matti Hamalainen <ccr@tnsp.org>
parents: 172
diff changeset
170 }