1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
|
<?php
// Google map module for phpGedView
//
// webtrees: Web based Family History software
// Copyright (C) 2011 webtrees development team.
//
// Derived from PhpGedView
// Copyright (C) 2002 to 2010 PGV Development Team. All rights reserved.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// $Id$
if (!defined('WT_WEBTREES')) {
header('HTTP/1.0 403 Forbidden');
exit;
}
// functions copied from print_fact_place
function print_fact_place_map($factrec) {
$ct = preg_match("/2 PLAC (.*)/", $factrec, $match);
if ($ct>0) {
$retStr = ' ';
$levels = explode(',', $match[1]);
$place = trim($match[1]);
// reverse the array so that we get the top level first
$levels = array_reverse($levels);
$retStr .= '<a href="placelist.php?action=show&';
foreach ($levels as $pindex=>$ppart) {
// routine for replacing ampersands
$ppart = preg_replace("/amp\%3B/", "", trim($ppart));
$retStr .= "parent[$pindex]=".PrintReady($ppart)."&";
}
$retStr .= 'level='.count($levels);
$retStr .= '"> '.PrintReady($place).'</a>';
return $retStr;
}
return '';
}
function print_address_structure_map($factrec, $level) {
global $WORD_WRAPPED_NOTES;
global $POSTAL_CODE;
// $POSTAL_CODE = 'false' - before city, 'true' - after city and/or state
//-- define per gedcom till can do per address countries in address languages
//-- then this will be the default when country not recognized or does not exist
//-- both Finland and Suomi are valid for Finland etc.
//-- see http://www.bitboost.com/ref/international-address-formats.html
$nlevel = $level+1;
$ct = preg_match_all("/$level ADDR(.*)/", $factrec, $omatch, PREG_SET_ORDER);
for ($i=0; $i<$ct; $i++) {
$arec = get_sub_record($level, "$level ADDR", $factrec, $i+1);
$resultText = '';
$cn = preg_match("/$nlevel _NAME (.*)/", $arec, $cmatch);
if ($cn>0) $resultText .= str_replace("/", "", $cmatch[1]).'<br />';
$resultText .= PrintReady(trim($omatch[$i][1]));
$cont = get_cont($nlevel, $arec);
if (!empty($cont)) $resultText .= str_replace(array(' ', "<br "), array(" ", "<br "), PrintReady($cont));
else {
if (strlen(trim($omatch[$i][1])) > 0) echo '<br />';
$cs = preg_match("/$nlevel ADR1 (.*)/", $arec, $cmatch);
if ($cs>0) {
if ($cn==0) {
$resultText .= '<br />';
$cn=0;
}
$resultText .= PrintReady($cmatch[1]);
}
$cs = preg_match("/$nlevel ADR2 (.*)/", $arec, $cmatch);
if ($cs>0) {
if ($cn==0) {
$resultText .= '<br />';
$cn=0;
}
$resultText .= PrintReady($cmatch[1]);
}
if ($POSTAL_CODE) {
if (preg_match("/$nlevel CITY (.*)/", $arec, $cmatch))
$resultText.=' '.PrintReady($cmatch[1]);
if (preg_match("/$nlevel STAE (.*)/", $arec, $cmatch))
$resultText.=', '.PrintReady($cmatch[1]);
if (preg_match("/$nlevel POST (.*)/", $arec, $cmatch))
$resultText.='<br />'.PrintReady($cmatch[1]);
} else {
if (preg_match("/$nlevel POST (.*)/", $arec, $cmatch))
$resultText.='<br />'.PrintReady($cmatch[1]);
if (preg_match("/$nlevel CITY (.*)/", $arec, $cmatch))
$resultText.=' '.PrintReady($cmatch[1]);
if (preg_match("/$nlevel STAE (.*)/", $arec, $cmatch))
$resultText.=', '.PrintReady($cmatch[1]);
}
}
if (preg_match("/$nlevel CTRY (.*)/", $arec, $cmatch))
$resultText.='<br />'.PrintReady($cmatch[1]);
$resultText.= '<br />';
// Here we can examine the resultant text and remove empty tags
echo str_replace(chr(10), ' ' , $resultText);
}
$resultText = "<table>";
$ct = preg_match_all("/$level PHON (.*)/", $factrec, $omatch, PREG_SET_ORDER);
for ($i=0; $i<$ct; $i++) {
$resultText .= '<tr><td><span class="label"><b>'.WT_Gedcom_Tag::getLabel('PHON').': </b></span></td><td><span class="field">';
$resultText .= getLRM() . $omatch[$i][1]. getLRM();
$resultText .= '</span></td></tr>';
}
$ct = preg_match_all("/$level FAX (.*)/", $factrec, $omatch, PREG_SET_ORDER);
for ($i=0; $i<$ct; $i++) {
$resultText .= '<tr><td><span class="label"><b>'.WT_Gedcom_Tag::getLabel('FAX').': </b></span></td><td><span class="field">';
$resultText .= getLRM() . $omatch[$i][1] . getLRM();
$resultText .= '</span></td></tr>';
}
$ct = preg_match_all("/$level EMAIL (.*)/", $factrec, $omatch, PREG_SET_ORDER);
for ($i=0; $i<$ct; $i++) {
$resultText .= '<tr><td><span class="label"><b>'.WT_Gedcom_Tag::getLabel('EMAIL').': </b></span></td><td><span class="field">';
$resultText .= '<a href="mailto:'.$omatch[$i][1].'">'.$omatch[$i][1].'</a>';
$resultText .= '</span></td></tr>';
}
$ct = preg_match_all("/$level (WWW|URL) (.*)/", $factrec, $omatch, PREG_SET_ORDER);
for ($i=0; $i<$ct; $i++) {
$resultText .= '<tr><td><span class="label"><b>'.WT_Gedcom_Tag::getLabel('URL').': </b></span></td><td><span class="field">';
$resultText .= '<a href="'.$omatch[$i][2].'" target="_blank">'.$omatch[$i][2].'</a>';
$resultText .= '</span></td></tr>';
}
$resultText .= '</table>';
if ($resultText!='<table></table>') echo str_replace(chr(10), ' ' , $resultText);
}
function rem_prefix_from_placename($prefix_list, $place, &$placelist) {
$prefix_split = explode(';', $prefix_list);
foreach ($prefix_split as $prefix) {
if ($prefix && substr($place, 0, strlen($prefix)+1)==$prefix.' ') {
$placelist[] = substr($place, strlen($prefix)+1);
}
}
return $placelist;
}
function rem_postfix_from_placename($postfix_list, $place, &$placelist) {
$postfix_split = explode (';', $postfix_list);
foreach ($postfix_split as $postfix) {
if ($postfix && substr($place, -strlen($postfix)-1)==' '.$postfix) {
$placelist[] = substr($place, 0, strlen($place)-strlen($postfix)-1);
}
}
return $placelist;
}
function rem_prefix_postfix_from_placename($prefix_list, $postfix_list, $place, &$placelist) {
$prefix_split = explode (";", $prefix_list);
$postfix_split = explode (";", $postfix_list);
foreach ($prefix_split as $prefix) {
foreach ($postfix_split as $postfix) {
if ($prefix && $postfix && substr($place, 0, strlen($prefix)+1)==$prefix.' ' && substr($place, -strlen($postfix)-1)==' '.$postfix) {
$placelist[] = substr($place, strlen($prefix)+1, strlen($place)-strlen($prefix)-strlen($postfix)-2);
}
}
}
return $placelist;
}
function create_possible_place_names ($placename, $level) {
global $GM_PREFIX, $GM_POSTFIX, $GM_PRE_POST_MODE;
$retlist = array();
switch (@$GM_PRE_POST_MODE[$level]) {
case 0: // 0: no pre/postfix
$retlist[] = $placename;
break;
case 1: // 1 = Normal name, Prefix, Postfix, Both
$retlist[] = $placename;
$retlist = rem_prefix_from_placename($GM_PREFIX[$level], $placename, $retlist);
$retlist = rem_postfix_from_placename($GM_POSTFIX[$level], $placename, $retlist);
$retlist = rem_prefix_postfix_from_placename($GM_PREFIX[$level], $GM_POSTFIX[$level], $placename, $retlist);
break;
case 2: // 2 = Normal name, Postfix, Prefix, Both
$retlist[] = $placename;
$retlist = rem_postfix_from_placename($GM_POSTFIX[$level], $placename, $retlist);
$retlist = rem_prefix_from_placename($GM_PREFIX[$level], $placename, $retlist);
$retlist = rem_prefix_postfix_from_placename($GM_PREFIX[$level], $GM_POSTFIX[$level], $placename, $retlist);
break;
case 3: // 3 = Prefix, Postfix, Both, Normal name
$retlist = rem_prefix_from_placename($GM_PREFIX[$level], $placename, $retlist);
$retlist = rem_postfix_from_placename($GM_POSTFIX[$level], $placename, $retlist);
$retlist = rem_prefix_postfix_from_placename($GM_PREFIX[$level], $GM_POSTFIX[$level], $placename, $retlist);
$retlist[] = $placename;
break;
case 4: // 4 = Postfix, Prefix, Both, Normal name
$retlist = rem_postfix_from_placename($GM_POSTFIX[$level], $placename, $retlist);
$retlist = rem_prefix_from_placename($GM_PREFIX[$level], $placename, $retlist);
$retlist = rem_prefix_postfix_from_placename($GM_PREFIX[$level], $GM_POSTFIX[$level], $placename, $retlist);
$retlist[] = $placename;
break;
case 5: // 5 = Prefix, Postfix, Normal name, Both
$retlist = rem_prefix_from_placename($GM_PREFIX[$level], $placename, $retlist);
$retlist = rem_postfix_from_placename($GM_POSTFIX[$level], $placename, $retlist);
$retlist[] = $placename;
$retlist = rem_prefix_postfix_from_placename($GM_PREFIX[$level], $GM_POSTFIX[$level], $placename, $retlist);
break;
case 6: // 6 = Postfix, Prefix, Normal name, Both
$retlist = rem_postfix_from_placename($GM_POSTFIX[$level], $placename, $retlist);
$retlist = rem_prefix_from_placename($GM_PREFIX[$level], $placename, $retlist);
$retlist[] = $placename;
$retlist = rem_prefix_postfix_from_placename($GM_PREFIX[$level], $GM_POSTFIX[$level], $placename, $retlist);
break;
}
return $retlist;
}
function abbreviate($text) {
if (utf8_strlen($text)>13) {
if (trim(utf8_substr($text, 10, 1))!='') {
$desc = utf8_substr($text, 0, 11).'.';
} else {
$desc = trim(utf8_substr($text, 0, 11));
}
}
else $desc = $text;
return $desc;
}
function get_lati_long_placelocation ($place) {
$parent = explode (',', $place);
$parent = array_reverse($parent);
$place_id = 0;
for ($i=0; $i<count($parent); $i++) {
$parent[$i] = trim($parent[$i]);
if (empty($parent[$i])) $parent[$i]='unknown';// GoogleMap module uses "unknown" while GEDCOM uses , ,
$placelist = create_possible_place_names($parent[$i], $i+1);
foreach ($placelist as $key => $placename) {
$pl_id=
WT_DB::prepare("SELECT pl_id FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place")
->execute(array($i, $place_id, $placename))
->fetchOne();
if (!empty($pl_id)) break;
}
if (empty($pl_id)) break;
$place_id = $pl_id;
}
$row=
// WT_DB::prepare("SELECT pl_lati, pl_long, pl_zoom, pl_icon, pl_level FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place")
WT_DB::prepare("SELECT pl_media, sv_lati, sv_long, sv_bearing, sv_elevation, sv_zoom, pl_lati, pl_long, pl_zoom, pl_icon, pl_level FROM `##placelocation` WHERE pl_id=? ORDER BY pl_place")
->execute(array($place_id))
->fetchOneRow();
if ($row) {
return array('media'=>$row->pl_media, 'sv_lati'=>$row->sv_lati, 'sv_long'=>$row->sv_long, 'sv_bearing'=>$row->sv_bearing, 'sv_elevation'=>$row->sv_elevation, 'sv_zoom'=>$row->sv_zoom, 'lati'=>$row->pl_lati, 'long'=>$row->pl_long, 'zoom'=>$row->pl_zoom, 'icon'=>$row->pl_icon, 'level'=>$row->pl_level);
} else {
return array();
}
}
function setup_map() {
global $GOOGLEMAP_MAP_TYPE, $GOOGLEMAP_MIN_ZOOM, $GOOGLEMAP_MAX_ZOOM;
?>
<!-- V3 ============ -->
<script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false&language=<?php echo WT_LOCALE; ?>" type="text/javascript"></script>
<!-- V3 ============ -->
<script type="text/javascript">
var minZoomLevel = <?php echo $GOOGLEMAP_MIN_ZOOM;?>;
var maxZoomLevel = <?php echo $GOOGLEMAP_MAX_ZOOM;?>;
var startZoomLevel = <?php echo $GOOGLEMAP_MAX_ZOOM;?>;
</script>
<?php
}
function build_indiv_map($indifacts, $famids) {
global $GOOGLEMAP_MAP_TYPE, $GOOGLEMAP_MIN_ZOOM, $GOOGLEMAP_MAX_ZOOM, $GEDCOM;
global $GOOGLEMAP_XSIZE, $GOOGLEMAP_YSIZE, $SHOW_LIVING_NAMES;
global $TEXT_DIRECTION, $GM_DEFAULT_TOP_VALUE, $GOOGLEMAP_COORD;
$zoomLevel = $GOOGLEMAP_MAX_ZOOM;
// Create the markers list array ===============================================================
$markers=array();
// Add the events to the markers list array=====================================================
//-- sort the facts into date order
sort_facts($indifacts);
$i = 0;
foreach ($indifacts as $key => $value) {
$fact = $value->getTag();
$fact_data=$value->getDetail();
$factrec = $value->getGedComRecord();
$placerec = null;
if ($value->getPlace()!=null) {
$placerec = get_sub_record(2, '2 PLAC', $factrec);
$addrFound = false;
} else {
if (preg_match("/\d ADDR (.*)/", $factrec, $match)) {
$placerec = get_sub_record(1, "\d ADDR", $factrec);
$addrFound = true;
}
}
if (!empty($placerec)) {
$ctla = preg_match("/\d LATI (.*)/", $placerec, $match1);
$ctlo = preg_match("/\d LONG (.*)/", $placerec, $match2);
$spouserec = get_sub_record(2, '2 _WTS', $factrec);
$ctlp = preg_match("/\d _WTS @(.*)@/", $spouserec, $spouseid);
if ($ctlp>0) {
$useThisItem = WT_Family::getInstance($spouseid[1])->canDisplayDetails();
} else {
$useThisItem = true;
}
if (($ctla>0) && ($ctlo>0) && ($useThisItem==true)) {
$i = $i + 1;
$markers[$i]=array('class'=>'optionbox', 'index'=>'', 'tabindex'=>'', 'placed'=>'no');
if ($fact == "EVEN" || $fact=="FACT") {
$eventrec = get_sub_record(1, '2 TYPE', $factrec);
if (preg_match("/\d TYPE (.*)/", $eventrec, $match3)) {
$markers[$i]['fact']=$match3[1];
} else {
$markers[$i]['fact']=WT_Gedcom_Tag::getLabel($fact);
}
} else {
$markers[$i]['fact']=WT_Gedcom_Tag::getLabel($fact);
}
if (!empty($fact_data) && $fact_data!='Y') {
$markers[$i]['info'] = $fact_data;
}
$markers[$i]['placerec'] = $placerec;
$match1[1] = trim($match1[1]);
$match2[1] = trim($match2[1]);
$markers[$i]['lati'] = str_replace(array('N', 'S', ','), array('', '-', '.') , $match1[1]);
$markers[$i]['lng'] = str_replace(array('E', 'W', ','), array('', '-', '.') , $match2[1]);
$ctd = preg_match("/2 DATE (.+)/", $factrec, $match);
if ($ctd>0) {
$markers[$i]['date'] = $match[1];
}
if ($ctlp>0) {
$markers[$i]['name']=$spouseid[1];
}
} else {
if ($useThisItem==true && $addrFound==false) {
$ctpl = preg_match("/\d PLAC (.*)/", $placerec, $match1);
$latlongval = get_lati_long_placelocation($match1[1]);
if ((count($latlongval) == 0) && (!empty($GM_DEFAULT_TOP_VALUE))) {
$latlongval = get_lati_long_placelocation($match1[1].', '.$GM_DEFAULT_TOP_VALUE);
if ((count($latlongval) != 0) && ($latlongval['level'] == 0)) {
$latlongval['lati'] = NULL;
$latlongval['long'] = NULL;
}
}
if ((count($latlongval) != 0) && ($latlongval['lati'] != NULL) && ($latlongval['long'] != NULL)) {
$i = $i + 1;
$markers[$i]=array('class'=>'optionbox', 'index'=>'', 'tabindex'=>'', 'placed'=>'no');
if ($fact == "EVEN" || $fact=="FACT") {
$eventrec = get_sub_record(1, '2 TYPE', $factrec);
if (preg_match("/\d TYPE (.*)/", $eventrec, $match3)) {
$markers[$i]['fact']=$match3[1];
} else {
$markers[$i]['fact']=WT_Gedcom_Tag::getLabel($fact);
}
} else {
$markers[$i]['fact']=WT_Gedcom_Tag::getLabel($fact);
}
if (!empty($fact_data) && $fact_data!='Y') {
$markers[$i]['info'] = $fact_data;
}
$markers[$i]['icon'] = $latlongval['icon'];
$markers[$i]['placerec'] = $placerec;
if ($zoomLevel > $latlongval['zoom']) {
$zoomLevel = $latlongval['zoom'];
}
$markers[$i]['lati'] = str_replace(array('N', 'S', ','), array('', '-', '.') , $latlongval['lati']);
$markers[$i]['lng'] = str_replace(array('E', 'W', ','), array('', '-', '.') , $latlongval['long']);
$markers[$i]['media'] = $latlongval['media'];
$markers[$i]['sv_lati'] = $latlongval['sv_lati'];
$markers[$i]['sv_long'] = $latlongval['sv_long'];
$markers[$i]['sv_bearing'] = $latlongval['sv_bearing'];
$markers[$i]['sv_elevation'] = $latlongval['sv_elevation'];
$markers[$i]['sv_zoom'] = $latlongval['sv_zoom'];
$ctd = preg_match("/2 DATE (.+)/", $factrec, $match);
if ($ctd>0) {
$markers[$i]['date'] = $match[1];
}
if ($ctlp>0) {
$markers[$i]['name']=$spouseid[1];
}
}
}
}
}
}
// Add children to the markers list array ======================================================
if (count($famids)>0) {
$hparents=false;
for ($f=0; $f<count($famids); $f++) {
if (!empty($famids[$f])) {
$famrec = find_gedcom_record($famids[$f], WT_GED_ID, true);
if ($famrec) {
$num = preg_match_all("/1\s*CHIL\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER);
for ($j=0; $j<$num; $j++) {
$person=WT_Person::getInstance($smatch[$j][1]);
if ($person->canDisplayDetails()) {
$srec = find_person_record($smatch[$j][1], WT_GED_ID);
$birthrec = '';
$placerec = '';
foreach ($person->getAllFactsByType('BIRT') as $sEvent) {
$birthrec = $sEvent->getGedcomRecord();
$placerec = get_sub_record(2, '2 PLAC', $birthrec);
if (!empty($placerec)) {
$ctd = preg_match("/\d DATE (.*)/", $birthrec, $matchd);
$ctla = preg_match("/\d LATI (.*)/", $placerec, $match1);
$ctlo = preg_match("/\d LONG (.*)/", $placerec, $match2);
if (($ctla>0) && ($ctlo>0)) {
$i = $i + 1;
$markers[$i]=array('index'=>'', 'tabindex'=>'', 'placed'=>'no');
if (strpos($srec, "\n1 SEX F")!==false) {
$markers[$i]['fact'] = WT_I18N::translate('daughter');
$markers[$i]['class'] = 'person_boxF';
} else {
if (strpos($srec, "\n1 SEX M")!==false) {
$markers[$i]['fact'] = WT_I18N::translate('son');
$markers[$i]['class'] = 'person_box';
} else {
$markers[$i]['fact'] = WT_I18N::translate('child');
$markers[$i]['class'] = 'person_boxNN';
}
}
$markers[$i]['placerec'] = $placerec;
$match1[1] = trim($match1[1]);
$match2[1] = trim($match2[1]);
$markers[$i]['lati'] = str_replace(array('N', 'S', ','), array('', '-', '.'), $match1[1]);
$markers[$i]['lng'] = str_replace(array('E', 'W', ','), array('', '-', '.'), $match2[1]);
if ($ctd > 0) {
$markers[$i]['date'] = $matchd[1];
}
$markers[$i]['name'] = $smatch[$j][1];
} else {
$ctpl = preg_match("/\d PLAC (.*)/", $placerec, $match1);
$latlongval = get_lati_long_placelocation($match1[1]);
if ((count($latlongval) == 0) && (!empty($GM_DEFAULT_TOP_VALUE))) {
$latlongval = get_lati_long_placelocation($match1[1].', '.$GM_DEFAULT_TOP_VALUE);
if ((count($latlongval) != 0) && ($latlongval['level'] == 0)) {
$latlongval['lati'] = NULL;
$latlongval['long'] = NULL;
}
}
if ((count($latlongval) != 0) && ($latlongval['lati'] != NULL) && ($latlongval['long'] != NULL)) {
$i = $i + 1;
$markers[$i]=array('index'=>'', 'tabindex'=>'', 'placed'=>'no');
$markers[$i]['fact'] = WT_I18N::translate('child');
$markers[$i]['class'] = 'option_boxNN';
if (strpos($srec, "\n1 SEX F")!==false) {
$markers[$i]['fact'] = WT_I18N::translate('daughter');
$markers[$i]['class'] = 'person_boxF';
}
if (strpos($srec, "\n1 SEX M")!==false) {
$markers[$i]['fact'] = WT_I18N::translate('son');
$markers[$i]['class'] = 'person_box';
}
$markers[$i]['icon'] = $latlongval['icon'];
$markers[$i]['placerec'] = $placerec;
if ($zoomLevel > $latlongval['zoom']) {
$zoomLevel = $latlongval['zoom'];
}
$markers[$i]['lati'] = str_replace(array('N', 'S', ','), array('', '-', '.'), $latlongval['lati']);
$markers[$i]['lng'] = str_replace(array('E', 'W', ','), array('', '-', '.'), $latlongval['long']);
if ($ctd > 0) {
$markers[$i]['date'] = $matchd[1];
}
$markers[$i]['name'] = $smatch[$j][1];
$markers[$i]['media'] = $latlongval['media'];
$markers[$i]['sv_lati'] = $latlongval['sv_lati'];
$markers[$i]['sv_long'] = $latlongval['sv_long'];
$markers[$i]['sv_bearing'] = $latlongval['sv_bearing'];
$markers[$i]['sv_elevation'] = $latlongval['sv_elevation'];
$markers[$i]['sv_zoom'] = $latlongval['sv_zoom'];
}
}
}
}
}
}
}
}
}
}
// Prepare the $markers array for use by the following "required" file/files ===================
if ($i == 0) {
echo '<table class="facts_table">';
echo '<tr><td colspan="2" class="facts_value">', WT_I18N::translate('No map data for this person');
echo '</td></tr>';
if (WT_USER_IS_ADMIN) {
echo '<tr><td class="center" colspan="2">';
echo '<a href="module.php?mod=googlemap&mod_action=admin_editconfig">', WT_I18N::translate('Google Maps configuration'), '</a>';
echo '</td></tr>';
}
} else {
$indexcounter = 0;
for ($j=1; $j<=$i; $j++) {
if ($markers[$j]['placed'] == 'no') {
$multimarker = -1;
// Count nr of locations where the long/lati is identical
for ($k=$j; $k<=$i; $k++) {
if (($markers[$j]['lati'] == $markers[$k]['lati']) && ($markers[$j]['lng'] == $markers[$k]['lng'])) {
$multimarker = $multimarker + 1;
}
}
// If only one location with this long/lati combination
if ($multimarker == 0) {
// --- NOTE for V3 api, following line is changed from "yes" to "no" -----------
// --- This aids in identifying multi-event locations
$markers[$j]['placed'] = 'no';
// -----------------------------------------------------------------------------
$markers[$j]['index'] = $indexcounter;
$markers[$j]['tabindex'] = 0;
$indexcounter = $indexcounter + 1;
} else {
$tabcounter = 0;
$markersindex = 0;
$markers[$j]['placed'] = 'yes';
$markers[$j]['index'] = $indexcounter;
$markers[$j]['tabindex'] = $tabcounter;
$tabcounter = $tabcounter + 1;
for ($k=$j+1; $k<=$i; $k++) {
if (($markers[$j]['lati'] == $markers[$k]['lati']) && ($markers[$j]['lng'] == $markers[$k]['lng'])) {
$markers[$k]['placed'] = 'yes';
$markers[$k]['index'] = $indexcounter;
// if ($tabcounter == 4) {
// V3 ==============================
if ($tabcounter == 30) {
// V3 ==============================
$indexcounter = $indexcounter + 1;
$tabcounter = 0;
$markersindex = $markersindex + 1;
}
$markers[$k]['index'] = $indexcounter;
$markers[$k]['tabindex'] = $tabcounter;
$tabcounter = $tabcounter + 1;
}
}
$indexcounter = $indexcounter + 1;
}
}
}
// === add $gmarks array to the required wt_v3_googlemap.js.php ============================
$gmarks = $markers;
global $controller;
$pid=$controller->record->getXref();
// === Include css and js files ============================================================
echo '<link type="text/css" href="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/css/wt_v3_googlemap.css" rel="stylesheet" />';
require_once WT_ROOT.WT_MODULES_DIR.'googlemap/wt_v3_googlemap.js.php';
// === Create the normal googlemap sidebar of events and children ==========================
echo '<div style="overflow: auto; overflow-x: hidden; overflow-y: auto; height:', $GOOGLEMAP_YSIZE, 'px;"><table class="facts_table">';
$z=0;
foreach($markers as $marker) {
echo '<tr>';
echo '<td class="facts_label">';
echo '<a href="javascript:myclick(', $z, ', ', $marker['index'], ', ', $marker['tabindex'], ')">', $marker['fact'], '</a></td>';
$z++;
echo '<td class="', $marker['class'], '" style="white-space: normal">';
if (!empty($marker['info'])) {
echo '<span class="field">', $marker['info'], '</span><br />';
}
if (!empty($marker['name'])) {
$person=WT_Person::getInstance($marker['name']);
if ($person) {
echo '<a href="', $person->getHtmlUrl(), '">', $person->getFullName(), '</a>';
}
echo '<br />';
}
if (preg_match("/2 PLAC (.*)/", $marker['placerec']) == 0) {
print_address_structure_map($marker['placerec'], 1);
} else {
echo print_fact_place_map($marker['placerec']), '<br />';
}
if (!empty($marker['date'])) {
$date=new WT_Date($marker['date']);
echo $date->Display(true), '<br />';
}
echo '</td>';
echo '</tr>';
}
echo '</table></div><br />';
} // end prepare markers array =================================================================
// ======= More V3 api stuff (not displayed now) but will be sorted later ==========
?>
<table id="s_bar" style="display:none;">
<tr>
<td valign="top" style="padding-left:5px; width:360px; text-decoration:none; color:#4444ff; background:#aabbd8;">
<div id="side_bar"></div>
</td>
</tr>
</table>
<table style="display:none;">
<tr>
<td style="width: 360px; text-align:center;">
<form style="width: 360px;" id="form1" action="#">
<!-- Event Map:<input name= "radio1" type="checkbox" id="theatrebox" onclick="boxclick(this,'theatre')" checked /> -->
Street View Only:<input name= "radio2" type="checkbox" id="golfbox" onclick="boxclick(this,'golf')" />
<!-- Other Map:<input type="checkbox" id="infobox" onclick="boxclick(this,'info')" /> -->
<?php
// --------- Maybe for later use ---------------
/*
Other Map:<input type="checkbox" id="infobox" onclick="boxclick(this,'info')" />
<b>Pedigree Map:</b><input id="sel2" name="select" type=radio />
Parents: <input type="checkbox" id="parentsbox" onclick="boxclick(this,'gen1')" />
Grandparents: <input type="checkbox" id="gparentsbox" onclick="boxclick(this,'gen2')" />
Great Grandparents: <input type="checkbox" id="ggparentsbox" onclick="boxclick(this,'gen3')" /><br />
*/
?>
</form>
</td>
<td style="width: 200px;">
</td>
</tr>
</table>
<?php
// =================================================================================
echo '<br />';
return $i;
} // end build_indiv_map function
|