Publicité
+ Répondre à la discussion
Affichage des résultats 1 à 2 sur 2
  1. #1
    Membre du Club
    Inscrit en
    mai 2005
    Messages
    181
    Détails du profil
    Informations forums :
    Inscription : mai 2005
    Messages : 181
    Points : 45
    Points
    45

    Par défaut Carte googlemap grisée

    Bonjour,

    Depuis quelques semaines, les cartes GoogleMap qu'on ajoutait sur des sites et qui fonctionnaient bien avant, ne fonctionnent plus, elles sont grisées maintenant.

    Impossible de trouver pourquoi : j'ai essayé de modifier en prenant d'autres classes googleMapApi mais ça fait pareil.

    Exemple de site : http://www.siteco1.etude-notaires.fr/alentours.php

    Voici mon code, auriez-vous une idée pourquoi svp ?

    Merci d'avance.

    Code :
    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
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    869
    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    891
    892
    893
    894
    895
    896
    897
    898
    899
    900
    901
    902
    903
    904
    905
    906
    907
    908
    909
    910
    911
    912
    913
    914
    915
    916
    917
    918
    919
    920
    921
    922
    923
    924
    925
    926
    927
    928
    929
    930
    931
    932
    933
    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    944
    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    955
    956
    957
    958
    959
    960
    961
    962
    963
    964
    965
    966
    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    978
    979
    980
    981
    982
    983
    984
    985
    986
    987
    988
    989
    990
    991
    992
    993
    994
    995
    996
    997
    998
    999
    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    1012
    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    1043
    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    1054
    1055
    1056
    1057
    1058
    1059
    1060
    1061
    1062
    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    1073
    1074
    1075
    1076
    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    1094
    1095
    1096
    1097
    1098
    1099
    1100
    1101
    1102
    1103
    1104
    1105
    1106
    1107
    1108
    1109
    1110
    1111
    1112
    1113
    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    1128
    1129
    1130
    1131
    1132
    1133
    1134
    1135
    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    1150
    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    1159
    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    1181
    1182
    1183
    1184
    1185
    1186
    1187
    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    1201
    1202
    1203
    1204
    1205
    1206
    1207
    1208
    1209
    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    1222
    1223
    1224
    1225
    1226
    1227
    1228
    1229
    1230
    1231
    1232
    1233
    1234
    1235
    1236
    1237
    1238
    1239
    1240
    1241
    1242
    1243
    1244
    1245
    1246
    1247
    1248
    1249
    1250
    1251
    1252
    1253
    1254
    1255
    1256
    1257
    1258
    1259
    1260
    1261
    1262
    1263
    1264
    1265
    1266
    1267
    1268
    1269
    1270
    1271
    1272
    1273
    1274
    1275
    1276
    1277
    1278
    1279
    1280
    1281
    1282
    1283
    1284
    1285
    1286
    1287
    1288
    1289
    1290
    1291
    1292
    1293
    1294
    1295
    1296
    1297
    1298
    1299
    1300
    1301
    1302
    1303
    1304
    1305
    1306
    1307
    1308
    1309
    1310
    1311
    1312
    1313
    1314
    1315
    1316
    1317
    1318
    1319
    1320
    1321
    1322
    1323
    1324
    1325
    1326
    1327
    1328
    1329
    1330
    1331
    1332
    1333
    1334
    1335
    1336
    1337
    1338
    1339
    1340
    1341
    1342
    1343
    1344
    1345
    1346
    1347
    1348
    1349
    1350
    1351
    1352
    1353
    1354
    1355
    1356
    1357
    1358
    1359
    1360
    1361
    1362
    1363
    1364
    1365
    1366
    1367
    1368
    1369
    1370
    1371
    1372
    1373
    1374
    1375
    1376
    1377
    1378
    1379
    1380
    1381
    1382
    1383
    1384
    1385
    1386
    1387
    1388
    1389
    1390
    1391
    1392
    1393
    1394
    1395
    1396
    1397
    1398
    1399
    1400
    1401
    1402
    1403
    1404
    1405
    1406
    1407
    1408
    1409
    1410
    1411
    1412
    1413
    1414
    1415
    1416
    1417
    1418
    1419
    1420
    1421
    1422
    1423
    1424
    1425
    1426
    1427
    1428
    1429
    1430
    1431
    1432
    1433
    1434
    1435
    1436
    1437
    1438
    1439
    1440
    1441
    1442
    1443
    1444
    1445
    1446
    1447
    1448
    1449
    1450
    1451
    1452
    1453
    1454
    1455
    1456
    1457
    1458
    1459
    1460
    1461
    1462
    1463
    1464
    1465
    1466
    1467
    1468
    1469
    1470
    1471
    1472
    1473
    1474
    1475
    1476
    1477
    1478
    1479
    1480
    <?php
     
    class GoogleMapAPI {
     
        /**
         * PEAR::DB DSN for geocode caching. example:
         * $dsn = 'mysql://user:pass@localhost/dbname';
         *
         * @var string
         */
        var $dsn = null;
     
        /**
         * YOUR GooglMap API KEY for your site.
         * (http://maps.google.com/apis/maps/signup.html)
         *
         * @var string
         */
        var $api_key = '';
     
        /**
         * current map id, set when you instantiate
         * the GoogleMapAPI object.
         *
         * @var string
         */
        var $map_id = null;
     
        /**
         * sidebar <div> used along with this map.
         *
         * @var string
         */
        var $sidebar_id = null;    
     
        /**
         * GoogleMapAPI uses the Yahoo geocode lookup API.
         * This is the application ID for YOUR application.
         * This is set upon instantiating the GoogleMapAPI object.
         * (http://developer.yahoo.net/faq/index.html#appid)
         *
         * @var string
         */
        var $app_id = null;
     
        /**
         * use onLoad() to load the map javascript.
         * if enabled, be sure to include on your webpage:
         * <html onload="onLoad()">
         *
         * @var string
         */
        var $onload = true;
     
        /**
         * map center latitude (horizontal)
         * calculated automatically as markers
         * are added to the map.
         *
         * @var float
         */
        var $center_lat = null;
     
        /**
         * map center longitude (vertical)
         * calculated automatically as markers
         * are added to the map.
         *
         * @var float
         */
        var $center_lon = null;
     
        /**
         * enables map controls (zoom/move/center)
         *
         * @var boolean
         */
        var $map_controls = true;
     
        /**
         * determines the map control type
         * small -> show move/center controls
         * large -> show move/center/zoom controls
         *
         * @var string
         */
        var $control_size = 'large';
     
        /**
         * enables map type controls (map/satellite/hybrid)
         *
         * @var boolean
         */
        var $type_controls = true;
     
        /**
         * default map type (G_NORMAL_MAP/G_SATELLITE_MAP/G_HYBRID_MAP)
         *
         * @var boolean
         */
        var $map_type = 'G_NORMAL_MAP';
     
        /**
         * enables scale map control
         *
         * @var boolean
         */
        var $scale_control = true;
     
        /**
         * enables overview map control
         *
         * @var boolean
         */
        var $overview_control = true;    
     
        /**
         * determines the default zoom level
         *
         * @var integer
         */
        var $zoom = 10;
     
        /**
         * determines the map width
         *
         * @var integer
         */
        var $width = '500px';
     
        /**
         * determines the map height
         *
         * @var integer
         */
        var $height = '500px';
     
        /**
         * message that pops up when the browser is incompatible with Google Maps.
         * set to empty string to disable.
         *
         * @var integer
         */
    	 //$e = utf8_decode("é");
        var $browser_alert = 'Desole Google Maps n\'est pas compatible avec votre navigateur.';
     
        /**
         * message that appears when javascript is disabled.
         * set to empty string to disable.
         *
         * @var string
         */
        var $js_alert = '<b>Javascript doit etre active pour utiliser Google Maps.</b>';
     
        /**
         * determines if sidebar is enabled
         *
         * @var boolean
         */
        var $sidebar = true;    
     
        /**
         * determines if to/from directions are included inside info window
         *
         * @var boolean
         */
        var $directions = true;
     
        /**
         * determines if map markers bring up an info window
         *
         * @var boolean
         */
        var $info_window = true;    
     
        /**
         * determines if info window appears with a click or mouseover
         *
         * @var string click/mouseover
         */
        var $window_trigger = 'click';    
     
        /**
         * what server geocode lookups come from
         *
         * available: YAHOO  Yahoo! API. US geocode lookups only.
         *            GOOGLE Google Maps. This can do international lookups,
         *                   but not an official API service so no guarantees.
         *            Note: GOOGLE is the default lookup service, please read
         *                  the Yahoo! terms of service before using their API.
         *
         * @var string service name
         */
        var $lookup_service = 'GOOGLE';
    	var $lookup_server = array('GOOGLE' => 'maps.google.com', 'YAHOO' => 'api.local.yahoo.com');
     
        var $driving_dir_text = array(
                'dir_to' => 'Start address: (include addr, city st/region)',
                'to_button_value' => 'Get Directions',
                'to_button_type' => 'submit',
                'dir_from' => 'End address: (include addr, city st/region)',
                'from_button_value' => 'Get Directions',
                'from_button_type' => 'submit',
                'dir_text' => 'Directions: ',
                'dir_tohere' => 'To here',
                'dir_fromhere' => 'From here'
                );             
     
     
        /**
         * version number
         *
         * @var string
         */
        var $_version = '2.2';
     
        /**
         * list of added markers
         *
         * @var array
         */
        var $_markers = array();
     
        /**
         * maximum longitude of all markers
         * 
         * @var float
         */
        var $_max_lon = -1000000;
     
        /**
         * minimum longitude of all markers
         *
         * @var float
         */
        var $_min_lon = 1000000;
     
        /**
         * max latitude
         *
         * @var float
         */
        var $_max_lat = -1000000;
     
        /**
         * min latitude
         *
         * @var float
         */
        var $_min_lat = 1000000;
     
        /**
         * determines if we should zoom to minimum level (above this->zoom value) that will encompass all markers
         *
         * @var boolean
         */
        var $zoom_encompass = true;
     
        /**
         * factor by which to fudge the boundaries so that when we zoom encompass, the markers aren't too close to the edge
         *
         * @var float
         */
        var $bounds_fudge = 0.01;
     
        /**
         * use the first suggestion by a google lookup if exact match not found
         *
         * @var float
         */
        var $use_suggest = false;
     
     
        /**
         * list of added polylines
         *
         * @var array
         */
        var $_polylines = array();    
     
        /**
         * icon info array
         *
         * @var array
         */
        var $_icons = array();
     
        /**
         * database cache table name
         *
         * @var string
         */
        var $_db_cache_table = 'GEOCODES';
     
     
        /**
         * class constructor
         *
         * @param string $map_id the id for this map
         * @param string $app_id YOUR Yahoo App ID
         */
        function GoogleMapAPI($map_id = 'map', $app_id = 'MyMapApp') {
            $this->map_id = $map_id;
            $this->sidebar_id = 'sidebar_' . $map_id;
            $this->app_id = $app_id;
        }
     
        /**
         * sets the PEAR::DB dsn
         *
         * @param string $dsn
         */
        function setDSN($dsn) {
            $this->dsn = $dsn;   
        }
     
        /**
         * sets YOUR Google Map API key
         *
         * @param string $key
         */
        function setAPIKey($key) {
            $this->api_key = $key;   
        }
     
        /**
         * sets the width of the map
         *
         * @param string $width
         */
        function setWidth($width) {
            if(!preg_match('!^(\d+)(.*)$!',$width,$_match))
                return false;
     
            $_width = $_match[1];
            $_type = $_match[2];
            if($_type == '%')
                $this->width = $_width . '%';
            else
                $this->width = $_width . 'px';
     
            return true;
        }
     
        /**
         * sets the height of the map
         *
         * @param string $height
         */
        function setHeight($height) {
            if(!preg_match('!^(\d+)(.*)$!',$height,$_match))
                return false;
     
            $_height = $_match[1];
            $_type = $_match[2];
            if($_type == '%')
                $this->height = $_height . '%';
            else
                $this->height = $_height . 'px';
     
            return true;
        }        
     
        /**
         * sets the default map zoom level
         *
         * @param string $level
         */
        function setZoomLevel($level) {
            $this->zoom = (int) $level;
        }    
     
        /**
         * enables the map controls (zoom/move)
         *
         */
        function enableMapControls() {
            $this->map_controls = true;
        }
     
        /**
         * disables the map controls (zoom/move)
         *
         */
        function disableMapControls() {
            $this->map_controls = false;
        }    
     
        /**
         * sets the map control size (large/small)
         *
         * @param string $size
         */
        function setControlSize($size) {
            if(in_array($size,array('large','small')))
                $this->control_size = $size;
        }            
     
        /**
         * enables the type controls (map/satellite/hybrid)
         *
         */
        function enableTypeControls() {
            $this->type_controls = true;
        }
     
        /**
         * disables the type controls (map/satellite/hybrid)
         *
         */
        function disableTypeControls() {
            $this->type_controls = false;
        }
     
        /**
         * set default map type (map/satellite/hybrid)
         *
         */
        function setMapType($type) {
            switch($type) {
                case 'hybrid':
                    $this->map_type = 'G_HYBRID_MAP';
                    break;
                case 'satellite':
                    $this->map_type = 'G_SATELLITE_MAP';
                    break;
                case 'map':
                default:
                    $this->map_type = 'G_NORMAL_MAP';
                    break;
            }       
        }    
     
        /**
         * enables onload
         *
         */
        function enableOnLoad() {
            $this->onload = true;
        }
     
        /**
         * disables onload
         *
         */
        function disableOnLoad() {
            $this->onload = false;
        }
     
        /**
         * enables sidebar
         *
         */
        function enableSidebar() {
            $this->sidebar = true;
        }
     
        /**
         * disables sidebar
         *
         */
        function disableSidebar() {
            $this->sidebar = false;
        }    
     
        /**
         * enables map directions inside info window
         *
         */
        function enableDirections() {
            $this->directions = true;
        }
     
        /**
         * disables map directions inside info window
         *
         */
        function disableDirections() {
            $this->directions = false;
        }    
     
        /**
         * set browser alert message for incompatible browsers
         *
         * @params $message string
         */
        function setBrowserAlert($message) {
            $this->browser_alert = $message;
        }
     
        /**
         * set <noscript> message when javascript is disabled
         *
         * @params $message string
         */
        function setJSAlert($message) {
            $this->js_alert = $message;
        }
     
        /**
         * enable map marker info windows
         */
        function enableInfoWindow() {
            $this->info_window = true;
        }
     
        /**
         * disable map marker info windows
         */
        function disableInfoWindow() {
            $this->info_window = false;
        }
     
        /**
         * set the info window trigger action
         *
         * @params $message string click/mouseover
         */
        function setInfoWindowTrigger($type) {
            switch($type) {
                case 'mouseover':
                    $this->window_trigger = 'mouseover';
                    break;
                default:
                    $this->window_trigger = 'click';
                    break;
                }
        }
     
        /**
         * enable zoom to encompass makers
         */
        function enableZoomEncompass() {
            $this->zoom_encompass = true;
        }
     
        /**
         * disable zoom to encompass makers
         */
        function disableZoomEncompass() {
            $this->zoom_encompass = false;
        }
     
        /**
         * set the boundary fudge factor
         */
        function setBoundsFudge($val) {
            $this->bounds_fudge = $val;
        }
     
        /**
         * enables the scale map control
         *
         */
        function enableScaleControl() {
            $this->scale_control = true;
        }
     
        /**
         * disables the scale map control
         *
         */
        function disableScaleControl() {
            $this->scale_control = false;
        }    
     
        /**
         * enables the overview map control
         *
         */
        function enableOverviewControl() {
            $this->overview_control = true;
        }
     
        /**
         * disables the overview map control
         *
         */
        function disableOverviewControl() {
            $this->overview_control = false;
         }    
     
     
        /**
         * set the lookup service to use for geocode lookups
         * default is YAHOO, you can also use GOOGLE.
         * NOTE: GOOGLE can to intl lookups, but is not an
         * official API, so use at your own risk.
         *
         */
        function setLookupService($service) {
            switch($service) {
                case 'GOOGLE':
                    $this->lookup_service = 'GOOGLE';
                    break;
                case 'YAHOO':
                default:
                    $this->lookup_service = 'YAHOO';
                    break;
            }       
        }
     
     
        /**
         * adds a map marker by address
         * 
         * @param string $address the map address to mark (street/city/state/zip)
         * @param string $title the title display in the sidebar
         * @param string $html the HTML block to display in the info bubble (if empty, title is used)
         */
        function addMarkerByAddress($address,$title = '',$html = '') {
            if(($_geocode = $this->getGeocode($address)) === false)
                return false;
            return $this->addMarkerByCoords($_geocode['lon'],$_geocode['lat'],$title,$html);
        }
     
        /**
         * adds a map marker by geocode
         * 
         * @param string $lon the map longitude (horizontal)
         * @param string $lat the map latitude (vertical)
         * @param string $title the title display in the sidebar
         * @param string $html|array $html 
         *     string: the HTML block to display in the info bubble (if empty, title is used)
         *     array: The title => content pairs for a tabbed info bubble     
         */
        // TODO make it so you can specify which tab you want the directions to appear in (add another arg)
        function addMarkerByCoords($lon,$lat,$title = '',$html = '') {
            $_marker['lon'] = $lon;
            $_marker['lat'] = $lat;
            $_marker['html'] = (is_array($html) || strlen($html) > 0) ? $html : $title;
            $_marker['title'] = $title;
            $this->_markers[] = $_marker;
            $this->adjustCenterCoords($_marker['lon'],$_marker['lat']);
            // return index of marker
            return count($this->_markers) - 1;
        }
     
        /**
         * adds a map polyline by address
         * if color, weight and opacity are not defined, use the google maps defaults
         * 
         * @param string $address1 the map address to draw from
         * @param string $address2 the map address to draw to
         * @param string $color the color of the line (format: #000000)
         * @param string $weight the weight of the line in pixels
         * @param string $opacity the line opacity (percentage)
         */
        function addPolyLineByAddress($address1,$address2,$color='',$weight=0,$opacity=0) {
            if(($_geocode1 = $this->getGeocode($address1)) === false)
                return false;
            if(($_geocode2 = $this->getGeocode($address2)) === false)
                return false;
            return $this->addPolyLineByCoords($_geocode1['lon'],$_geocode1['lat'],$_geocode2['lon'],$_geocode2['lat'],$color,$weight,$opacity);
        }
     
        /**
         * adds a map polyline by map coordinates
         * if color, weight and opacity are not defined, use the google maps defaults
         * 
         * @param string $lon1 the map longitude to draw from
         * @param string $lat1 the map latitude to draw from
         * @param string $lon2 the map longitude to draw to
         * @param string $lat2 the map latitude to draw to
         * @param string $color the color of the line (format: #000000)
         * @param string $weight the weight of the line in pixels
         * @param string $opacity the line opacity (percentage)
         */
        function addPolyLineByCoords($lon1,$lat1,$lon2,$lat2,$color='',$weight=0,$opacity=0) {
            $_polyline['lon1'] = $lon1;
            $_polyline['lat1'] = $lat1;
            $_polyline['lon2'] = $lon2;
            $_polyline['lat2'] = $lat2;
            $_polyline['color'] = $color;
            $_polyline['weight'] = $weight;
            $_polyline['opacity'] = $opacity;
            $this->_polylines[] = $_polyline;
            $this->adjustCenterCoords($_polyline['lon1'],$_polyline['lat1']);
            $this->adjustCenterCoords($_polyline['lon2'],$_polyline['lat2']);
            // return index of polyline
            return count($this->_polylines) - 1;
        }        
     
        /**
         * adjust map center coordinates by the given lat/lon point
         * 
         * @param string $lon the map latitude (horizontal)
         * @param string $lat the map latitude (vertical)
         */
        function adjustCenterCoords($lon,$lat) {
            if(strlen((string)$lon) == 0 || strlen((string)$lat) == 0)
                return false;
            $this->_max_lon = (float) max($lon, $this->_max_lon);
            $this->_min_lon = (float) min($lon, $this->_min_lon);
            $this->_max_lat = (float) max($lat, $this->_max_lat);
            $this->_min_lat = (float) min($lat, $this->_min_lat);
     
            $this->center_lon = (float) ($this->_min_lon + $this->_max_lon) / 2;
            $this->center_lat = (float) ($this->_min_lat + $this->_max_lat) / 2;
            return true;
        }
     
        /**
         * set map center coordinates to lat/lon point
         * 
         * @param string $lon the map latitude (horizontal)
         * @param string $lat the map latitude (vertical)
         */
        function setCenterCoords($lon,$lat) {
            $this->center_lat = (float) $lat;
            $this->center_lon = (float) $lon;
        }    
     
        /**
         * generate an array of params for a new marker icon image
         * iconShadowImage is optional
         * If anchor coords are not supplied, we use the center point of the image by default. 
         * Can be called statically. For private use by addMarkerIcon() and setMarkerIcon()
         *
         * @param string $iconImage URL to icon image
         * @param string $iconShadowImage URL to shadow image
         * @param string $iconAnchorX X coordinate for icon anchor point
         * @param string $iconAnchorY Y coordinate for icon anchor point
         * @param string $infoWindowAnchorX X coordinate for info window anchor point
         * @param string $infoWindowAnchorY Y coordinate for info window anchor point
         */
        function createMarkerIcon($iconImage,$iconShadowImage = '',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x') {
            $_icon_image_path = strpos($iconImage,'http') === 0 ? $iconImage : $_SERVER['DOCUMENT_ROOT'] . $iconImage;
            if(!($_image_info = @getimagesize($_icon_image_path))) {
                die('GoogleMapAPI:createMarkerIcon: Error reading image: ' . $iconImage);   
            }
            if($iconShadowImage) {
                $_shadow_image_path = strpos($iconShadowImage,'http') === 0 ? $iconShadowImage : $_SERVER['DOCUMENT_ROOT'] . $iconShadowImage;
                if(!($_shadow_info = @getimagesize($_shadow_image_path))) {
                    die('GoogleMapAPI:createMarkerIcon: Error reading image: ' . $iconShadowImage);
                }
            }
     
            if($iconAnchorX === 'x') {
                $iconAnchorX = (int) ($_image_info[0] / 2);
            }
            if($iconAnchorY === 'x') {
                $iconAnchorY = (int) ($_image_info[1] / 2);
            }
            if($infoWindowAnchorX === 'x') {
                $infoWindowAnchorX = (int) ($_image_info[0] / 2);
            }
            if($infoWindowAnchorY === 'x') {
                $infoWindowAnchorY = (int) ($_image_info[1] / 2);
            }
     
            $icon_info = array(
                    'image' => $iconImage,
                    'iconWidth' => $_image_info[0],
                    'iconHeight' => $_image_info[1],
                    'iconAnchorX' => $iconAnchorX,
                    'iconAnchorY' => $iconAnchorY,
                    'infoWindowAnchorX' => $infoWindowAnchorX,
                    'infoWindowAnchorY' => $infoWindowAnchorY
                    );
            if($iconShadowImage) {
                $icon_info = array_merge($icon_info, array('shadow' => $iconShadowImage,
                                                           'shadowWidth' => $_shadow_info[0],
                                                           'shadowHeight' => $_shadow_info[1]));
            }
            return $icon_info;
        }
     
        /**
         * set the marker icon for ALL markers on the map
         */
        function setMarkerIcon($iconImage,$iconShadowImage = '',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x') {
            $this->_icons = array($this->createMarkerIcon($iconImage,$iconShadowImage,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY));
        }
     
        /**
         * add an icon to go with the correspondingly added marker
         */
        function addMarkerIcon($iconImage,$iconShadowImage = '',$iconAnchorX = 'x',$iconAnchorY = 'x',$infoWindowAnchorX = 'x',$infoWindowAnchorY = 'x') {
            $this->_icons[] = $this->createMarkerIcon($iconImage,$iconShadowImage,$iconAnchorX,$iconAnchorY,$infoWindowAnchorX,$infoWindowAnchorY);
            return count($this->_icons) - 1;
        }
     
        /**
         * print map header javascript (goes between <head></head>)
         * 
         */
        function printHeaderJS() {
            echo $this->getHeaderJS();   
        }
     
        /**
         * return map header javascript (goes between <head></head>)
         * 
         */
        function getHeaderJS() {
            return sprintf('<script src="http://maps.google.com/maps?file=api&v=2&key=%s" type="text/javascript" charset="utf-8"></script>', $this->api_key);
        }    
     
       /**                                                                                                                          
        * prints onLoad() without having to manipulate body tag.                                                                     
        * call this after the print map like so...                                                                             
        *      $map->printMap();                                                                                                     
        *      $map->printOnLoad();                                                                                                  
        */                                                                                                                           
        function printOnLoad() {
            echo $this->getOnLoad();
        }
     
        /**
         * return js to set onload function
         */
        function getOnLoad() {
            return '<script language="javascript" type="text/javascript" charset="utf-8">window.onload=onLoad;</script>';                       
        }
     
        /**
         * print map javascript (put just before </body>, or in <header> if using onLoad())
         * 
         */
        function printMapJS() {
            echo $this->getMapJS();
        }    
     
        /**
         * return map javascript
         * 
         */
        function getMapJS() {
            $_output = '<script type="text/javascript" charset="utf-8">' . "\n";
            $_output .= '//<![CDATA[' . "\n";
            $_output .= "/*************************************************\n";
            $_output .= " * Created with GoogleMapAPI " . $this->_version . "\n";
            $_output .= " *************************************************/\n";
     
            $_output .= 'var points = [];' . "\n";
            $_output .= 'var markers = [];' . "\n";
            $_output .= 'var counter = 0;' . "\n";
            if($this->sidebar) {        
                $_output .= 'var sidebar_html = "";' . "\n";
                $_output .= 'var marker_html = [];' . "\n";
            }
     
            if($this->directions) {        
                $_output .= 'var to_htmls = [];' . "\n";
                $_output .= 'var from_htmls = [];' . "\n";
            }        
     
            if(!empty($this->_icons)) {
                $_output .= 'var icon = [];' . "\n";
                for($i = 0; $this->_icons[$i]; $i++) {
                    $info = $this->_icons[$i];
     
                    // hash the icon data to see if we've already got this one; if so, save some javascript
                    $icon_key = md5(serialize($info));
                    if(!is_numeric($exist_icn[$icon_key])) {
                        $exist_icn[$icon_key] = $i;
     
                        $_output .= "icon[$i] = new GIcon();\n";   
                        $_output .= sprintf('icon[%s].image = "%s";',$i,$info['image']) . "\n";   
                        if($info['shadow']) {
                            $_output .= sprintf('icon[%s].shadow = "%s";',$i,$info['shadow']) . "\n";
                            $_output .= sprintf('icon[%s].shadowSize = new GSize(%s,%s);',$i,$info['shadowWidth'],$info['shadowHeight']) . "\n";   
                        }
                        $_output .= sprintf('icon[%s].iconSize = new GSize(%s,%s);',$i,$info['iconWidth'],$info['iconHeight']) . "\n";   
                        $_output .= sprintf('icon[%s].iconAnchor = new GPoint(%s,%s);',$i,$info['iconAnchorX'],$info['iconAnchorY']) . "\n";   
                        $_output .= sprintf('icon[%s].infoWindowAnchor = new GPoint(%s,%s);',$i,$info['infoWindowAnchorX'],$info['infoWindowAnchorY']) . "\n";
                    } else {
                        $_output .= "icon[$i] = icon[$exist_icn[$icon_key]];\n";
                    }
                }
            }
     
            $_output .= 'var map = null;' . "\n";
     
            if($this->onload) {
               $_output .= 'function onLoad() {' . "\n";   
            }
     
            if(!empty($this->browser_alert)) {
                $_output .= 'if (GBrowserIsCompatible()) {' . "\n";
            }
     
            $_output .= sprintf('var mapObj = document.getElementById("%s");',$this->map_id) . "\n";
            $_output .= 'if (mapObj != "undefined" && mapObj != null) {' . "\n";
            $_output .= sprintf('map = new GMap2(document.getElementById("%s"));',$this->map_id) . "\n";
     
            /*** ajout par moi **/
           // $_output .= sprintf('document.getElementById("%s").style.backgroundImage = "url(loading.jpg)";',$this->map_id) . "\n";
            if(isset($this->center_lat) && isset($this->center_lon)) {
                $_output .= sprintf('map.setCenter(new GLatLng(%s, %s), %s, %s);', $this->center_lat, $this->center_lon, $this->zoom, $this->map_type) . "\n";
     
            }
     
            // zoom so that all markers are in the viewport
            if($this->zoom_encompass && count($this->_markers) > 1) {
                // increase bounds by fudge factor to keep
                // markers away from the edges
                $_len_lon = $this->_max_lon - $this->_min_lon;
                $_len_lat = $this->_max_lat - $this->_min_lat;
                $this->_min_lon -= $_len_lon * $this->bounds_fudge;
                $this->_max_lon += $_len_lon * $this->bounds_fudge;
                $this->_min_lat -= $_len_lat * $this->bounds_fudge;
                $this->_max_lat += $_len_lat * $this->bounds_fudge;
     
                $_output .= "var bds = new GLatLngBounds(new GLatLng($this->_min_lat, $this->_min_lon), new GLatLng($this->_max_lat, $this->_max_lon));\n";
                $_output .= 'map.setZoom(map.getBoundsZoomLevel(bds));' . "\n";
     
            }
            /***** zoom de la molette de la souris *****/
            //$_output .= 'map.enableScrollWheelZoom();' . "\n";
     
            if($this->map_controls) {
              if($this->control_size == 'large')
                  $_output .= 'map.addControl(new GLargeMapControl());' . "\n";
              else
                  $_output .= 'map.addControl(new GSmallMapControl());' . "\n";
            }
            if($this->type_controls) {
                $_output .= 'map.addControl(new GMapTypeControl());' . "\n";
            }
     
            if($this->scale_control) {
                $_output .= 'map.addControl(new GScaleControl());' . "\n";
            }
     
            if($this->overview_control) {
                $_output .= 'map.addControl(new GOverviewMapControl());' . "\n";
            }
     
            $_output .= $this->getAddMarkersJS();
     
            $_output .= $this->getPolylineJS();
     
            if($this->sidebar) {
                //$_output .= sprintf('document.getElementById("%s").innerHTML = "<ul class=\"gmapSidebar\">"+ sidebar_html +"</ul>";', $this->sidebar_id) . "\n";
                $_output .= sprintf('document.getElementById("%s").innerHTML =  sidebar_html ;', $this->sidebar_id) . "\n";
                $_output .= sprintf('document.getElementById("%s").style.overflow = "auto";', $this->sidebar_id) . "\n";
                $_output .= sprintf('document.getElementById("%s").style.height = "450px";', $this->sidebar_id) . "\n";
               // $_output .= sprintf('document.getElementById("%s").style.width = "160px";', $this->sidebar_id) . "\n";
            }
     
            $_output .= '}' . "\n";        
     
            if(!empty($this->browser_alert)) {
                $_output .= '} else {' . "\n";
                $_output .= 'alert("' . $this->browser_alert . '");' . "\n";
                $_output .= '}' . "\n";
            }                        
     
            if($this->onload) {
               $_output .= '}' . "\n";
            }
     
            $_output .= $this->getCreateMarkerJS();
     
            // Utility functions used to distinguish between tabbed and non-tabbed info windows
            $_output .= 'function isArray(a) {return isObject(a) && a.constructor == Array;}' . "\n";
            $_output .= 'function isObject(a) {return (a && typeof a == \'object\') || isFunction(a);}' . "\n";
            $_output .= 'function isFunction(a) {return typeof a == \'function\';}' . "\n";
     
            if($this->sidebar) {        
                $_output .= 'function click_sidebar(idx) {' . "\n";
                $_output .= '  if(isArray(marker_html[idx])) { markers[idx].openInfoWindowTabsHtml(marker_html[idx]); }' . "\n";
                $_output .= '  else { markers[idx].openInfoWindowHtml(marker_html[idx]); }' . "\n";
                $_output .= '}' . "\n";
            }
            $_output .= 'function showInfoWindow(idx,html) {' . "\n";
            $_output .= 'map.centerAtLatLng(points[idx]);' . "\n";
            $_output .= 'markers[idx].openInfoWindowHtml(html);' . "\n";
            $_output .= '}' . "\n";
            if($this->directions) {
                $_output .= 'function tohere(idx) {' . "\n";
                $_output .= 'markers[idx].openInfoWindowHtml(to_htmls[idx]);' . "\n";
                $_output .= '}' . "\n";
                $_output .= 'function fromhere(idx) {' . "\n";
                $_output .= 'markers[idx].openInfoWindowHtml(from_htmls[idx]);' . "\n";
                $_output .= '}' . "\n";
            }
     
            $_output .= '//]]>' . "\n";
            $_output .= '</script>' . "\n";
            return $_output;
        }
     
        /**
         * overridable function for generating js to add markers
         */
        function getAddMarkersJS() {
            $SINGLE_TAB_WIDTH = 88;    // constant: width in pixels of each tab heading (set by google)
            $i = 0;
            $_output = '';
            foreach($this->_markers as $_marker) {
                if(is_array($_marker['html'])) {
                    // warning: you can't have two tabs with the same header. but why would you want to?
                    $ti = 0;
                    $num_tabs = count($_marker['html']);
                    $tab_obs = array();
                    foreach($_marker['html'] as $tab => $info) {
                        if($ti == 0 && $num_tabs > 2) {
                            $width_style = sprintf(' style=\"width: %spx\"', $num_tabs * $SINGLE_TAB_WIDTH);
                        } else {
                            $width_style = '';
                        }
                        $tab = str_replace('"','\"',$tab);
                        $info = str_replace('"','\"',$info);
                        $tab_obs[] = sprintf('new GInfoWindowTab("%s", "%s")', $tab, '<div id=\"gmapmarker\"'.$width_style.'>' . $info . '</div>');
                        $ti++;
                    }
                    $iw_html = '[' . join(',',$tab_obs) . ']';
                } else {
                    $iw_html = sprintf('"%s"',str_replace('"','\"','<div id="gmapmarker">' . $_marker['html'] . '</div>'));
                }
                $_output .= sprintf('var point = new GLatLng(%s,%s);',$_marker['lat'],$_marker['lon']) . "\n";         
                $_output .= sprintf('var marker = createMarker(point,"%s",%s, %s);',
                                    str_replace('"','\"',$_marker['title']),
                                    $iw_html,
                                    $i) . "\n";
                //TODO: in above createMarker call, pass the index of the tab in which to put directions, if applicable
                $_output .= 'map.addOverlay(marker);' . "\n";
                $i++;
            }
            return $_output;
        }
     
        /**
         * overridable function to generate polyline js
         */
        function getPolylineJS() {
            $_output = '';
            foreach($this->_polylines as $_polyline) {
                $_output .= sprintf('var polyline = new GPolyline([new GLatLng(%s,%s),new GLatLng(%s,%s)],"%s",%s,%s);',
                        $_polyline['lat1'],$_polyline['lon1'],$_polyline['lat2'],$_polyline['lon2'],$_polyline['color'],$_polyline['weight'],$_polyline['opacity'] / 100.0) . "\n";
                $_output .= 'map.addOverlay(polyline);' . "\n";
            }
            return $_output;
        }
     
        /**
         * overridable function to generate the js for the js function for creating a marker.
         */
        function getCreateMarkerJS() {
            $_output = 'function createMarker(point, title, html, n) {' . "\n";
            $_output .= 'if(n >= '. sizeof($this->_icons) .') { n = '. (sizeof($this->_icons) - 1) ."; }\n";
            if(!empty($this->_icons)) {
                $_output .= 'var marker = new GMarker(point,{\'icon\': icon[n]});' . "\n";
            } else {
                $_output .= 'var marker = new GMarker(point);' . "\n";
            }
            // TODO: make it so you can specify which tab you want the directions in.
            if($this->directions) {
                // WARNING: If you are using a tabbed info window AND directions: this uses an UNDOCUMENTED field
                // of the GInfoWindowTab object, contentElem. Google may CHANGE this name or other aspects of their
                // GInfoWindowTab implementation without warning and BREAK this code.
                // NOTE: If you are NOT using a tabbed info window, you'll be fine.
                $_output .= 'var tabFlag = isArray(html);' . "\n";
                $_output .= 'if(!tabFlag) { html = [{"contentElem": html}]; }' . "\n";
                $_output .= sprintf(
                         "to_htmls[counter] = html[0].contentElem + '<p /><form class=\"gmapDir\" id=\"gmapDirTo\" style=\"white-space: nowrap;\" action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\">' +
                         '<span class=\"gmapDirHead\" id=\"gmapDirHeadTo\">%s<strong>%s</strong> - <a href=\"javascript:fromhere(' + counter + ')\">%s</a></span>' +
                         '<p class=\"gmapDirItem\" id=\"gmapDirItemTo\"><label for=\"gmapDirSaddr\" class=\"gmapDirLabel\" id=\"gmapDirLabelTo\">%s<br /></label>' +
                         '<input type=\"text\" size=\"40\" maxlength=\"40\" name=\"saddr\" class=\"gmapTextBox\" id=\"gmapDirSaddr\" value=\"\" onfocus=\"this.style.backgroundColor = \'#e0e0e0\';\" onblur=\"this.style.backgroundColor = \'#ffffff\';\" />' +
                         '<span class=\"gmapDirBtns\" id=\"gmapDirBtnsTo\"><input value=\"%s\" type=\"%s\" class=\"gmapDirButton\" id=\"gmapDirButtonTo\" /></span></p>' +
                         '<input type=\"hidden\" name=\"daddr\" value=\"' +
                         point.y + ',' + point.x + \"(\" + title.replace(new RegExp(/\"/g),'"') + \")\" + '\" /></form>';
                          from_htmls[counter] = html[0].contentElem + '<p /><form class=\"gmapDir\" id=\"gmapDirFrom\" style=\"white-space: nowrap;\" action=\"http://maps.google.com/maps\" method=\"get\" target=\"_blank\">' +
                         '<span class=\"gmapDirHead\" id=\"gmapDirHeadFrom\">%s<a href=\"javascript:tohere(' + counter + ')\">%s</a> - <strong>%s</strong></span>' +
                         '<p class=\"gmapDirItem\" id=\"gmapDirItemFrom\"><label for=\"gmapDirSaddr\" class=\"gmapDirLabel\" id=\"gmapDirLabelFrom\">%s<br /></label>' +
                         '<input type=\"text\" size=\"40\" maxlength=\"40\" name=\"saddr\" class=\"gmapTextBox\" id=\"gmapDirSaddr\" value=\"\" onfocus=\"this.style.backgroundColor = \'#e0e0e0\';\" onblur=\"this.style.backgroundColor = \'#ffffff\';\" />' +
                         '<span class=\"gmapDirBtns\" id=\"gmapDirBtnsFrom\"><input value=\"%s\" type=\"%s\" class=\"gmapDirButton\" id=\"gmapDirButtonFrom\" /></span></p' +
                         '<input type=\"hidden\" name=\"daddr\" value=\"' +
                         point.y + ',' + point.x + \"(\" + title.replace(new RegExp(/\"/g),'"') + \")\" + '\" /></form>';
                         html[0].contentElem = html[0].contentElem + '<p /><div id=\"gmapDirHead\" class=\"gmapDir\" style=\"white-space: nowrap;\">%s<a href=\"javascript:tohere(' + counter + ')\">%s</a> - <a href=\"javascript:fromhere(' + counter + ')\">%s</a></div>';\n",
                         $this->driving_dir_text['dir_text'],
                         $this->driving_dir_text['dir_tohere'],
                         $this->driving_dir_text['dir_fromhere'],
                         $this->driving_dir_text['dir_to'],
                         $this->driving_dir_text['to_button_value'],
                         $this->driving_dir_text['to_button_type'],
                         $this->driving_dir_text['dir_text'],
                         $this->driving_dir_text['dir_tohere'],
                         $this->driving_dir_text['dir_fromhere'],
                         $this->driving_dir_text['dir_from'],
                         $this->driving_dir_text['from_button_value'],
                         $this->driving_dir_text['from_button_type'],
                         $this->driving_dir_text['dir_text'],
                         $this->driving_dir_text['dir_tohere'],
                         $this->driving_dir_text['dir_fromhere']
                        );
                $_output .= 'if(!tabFlag) { html = html[0].contentElem; }';
            }
            //fardeen
            //$_output .= "html += '<br/><a href=\"javascript:ZoomMapTo(' + counter + ')\">Zoom to</a>';\n";
     
            if($this->info_window) {
                $_output .= sprintf('if(isArray(html)) { GEvent.addListener(marker, "%s", function() { marker.openInfoWindowTabsHtml(html); }); }',$this->window_trigger) . "\n";
                $_output .= sprintf('else { GEvent.addListener(marker, "%s", function() { marker.openInfoWindowHtml(html); }); }',$this->window_trigger) . "\n";
            }
     
     
     
            $_output .= 'points[counter] = point;' . "\n";
            $_output .= 'markers[counter] = marker;' . "\n";
            if($this->sidebar) {        
                $_output .= 'marker_html[counter] = html;' . "\n";
                $_output .= "sidebar_html += '<li class=\"gmapSidebarItem\" id=\"gmapSidebarItem_'+ counter +'\"><a href=\"javascript:click_sidebar(' + counter + ')\">' + title + '</a></li>';" . "\n";
            }
            $_output .= 'counter++;' . "\n";
            $_output .= 'return marker;' . "\n";
            $_output .= '}' . "\n";
            return $_output;
        }
     
        /**
         * print map (put at location map will appear)
         * 
         */
        function printMap() {
            echo $this->getMap();
        }
     
        /**
         * return map
         * 
         */
        function getMap() {
            $_output = '<script type="text/javascript" charset="utf-8">' . "\n" . '//<![CDATA[' . "\n";
            $_output .= 'if (GBrowserIsCompatible()) {' . "\n";
            if(strlen($this->width) > 0 && strlen($this->height) > 0) {
                $_output .= sprintf('document.write(\'<div id="%s" style="width: %s; height: %s"></div>\');',$this->map_id,$this->width,$this->height) . "\n";
            } else {
                $_output .= sprintf('document.write(\'<div id="%s"></div>\');',$this->map_id) . "\n";     
            }
            $_output .= '}';
     
            if(!empty($this->js_alert)) {
                $_output .= ' else {' . "\n";
                $_output .= sprintf('document.write(\'%s\');', $this->js_alert) . "\n";
                $_output .= '}' . "\n";
            }
     
            $_output .= '//]]>' . "\n" . '</script>' . "\n";
     
            if(!empty($this->js_alert)) {
                $_output .= '<noscript>' . $this->js_alert . '</noscript>' . "\n";
            }
     
            return $_output;
        }
     
     
        /**
         * print sidebar (put at location sidebar will appear)
         * 
         */
        function printSidebar() {
            echo $this->getSidebar();
        }    
     
        /**
         * return sidebar html
         * 
         */
        function getSidebar() {
            return sprintf('<br/><div id="%s"></div>',$this->sidebar_id) . "\n";
        }    
     
        /**
         * get the geocode lat/lon points from given address
         * look in cache first, otherwise get from Yahoo
         * 
         * @param string $address
         */
        function getGeocode($address) {
            if(empty($address))
                return false;
     
            $_geocode = false;
     
            if(($_geocode = $this->getCache($address)) === false) {
                if(($_geocode = $this->geoGetCoords($address)) !== false) {
                    $this->putCache($address, $_geocode['lon'], $_geocode['lat']);
                }
            }
     
            return $_geocode;
        }
     
        /**
         * get the geocode lat/lon points from cache for given address
         * 
         * @param string $address
         */
        function getCache($address) {
            if(!isset($this->dsn))
                return false;
     
            $_ret = array();
     
            // PEAR DB
            require_once('DB.php');          
            $_db =& DB::connect($this->dsn);
            if (PEAR::isError($_db)) {
                die($_db->getMessage());
            }
    		$_res =& $_db->query("SELECT lon,lat FROM {$this->_db_cache_table} where address = ?", $address);
            if (PEAR::isError($_res)) {
                die($_res->getMessage());
            }
            if($_row = $_res->fetchRow()) {            
                $_ret['lon'] = $_row[0];
                $_ret['lat'] = $_row[1];
            }
     
            $_db->disconnect();
     
            return !empty($_ret) ? $_ret : false;
        }
     
        /**
         * put the geocode lat/lon points into cache for given address
         * 
         * @param string $address
         * @param string $lon the map latitude (horizontal)
         * @param string $lat the map latitude (vertical)
         */
        function putCache($address, $lon, $lat) {
            if(!isset($this->dsn) || (strlen($address) == 0 || strlen($lon) == 0 || strlen($lat) == 0))
               return false;
            // PEAR DB
            require_once('DB.php');          
            $_db =& DB::connect($this->dsn);
            if (PEAR::isError($_db)) {
                die($_db->getMessage());
            }
     
            $_res =& $_db->query('insert into ? values (?, ?, ?)', array($this->_db_cache_table,$address, $lon, $lat));
            if (PEAR::isError($_res)) {
                die($_res->getMessage());
            }
            $_db->disconnect();
     
            return true;
     
        }
     
        /**
         * get geocode lat/lon points for given address from Yahoo
         * 
         * @param string $address
         */
        function geoGetCoords($address,$depth=0) {
     
            switch($this->lookup_service) {
     
                case 'GOOGLE':
     
                    $_url = sprintf('http://%s/maps/geo?&q=%s&output=csv&key=%s',$this->lookup_server['GOOGLE'],rawurlencode($address),$this->api_key);
     
                    $_result = false;
     
                    if($_result = $this->fetchURL($_url)) {
     
                        $_result_parts = explode(',',$_result);
                        if($_result_parts[0] != 200)
                            return false;
                        $_coords['lat'] = $_result_parts[2];
                        $_coords['lon'] = $_result_parts[3];
                    }
     
                    break;
     
                case 'YAHOO':
                default:
     
                    $_url = 'http://%s/MapsService/V1/geocode';
                    $_url .= sprintf('?appid=%s&location=%s',$this->lookup_server['YAHOO'],$this->app_id,rawurlencode($address));
     
                    $_result = false;
     
                    if($_result = $this->fetchURL($_url)) {
     
                        preg_match('!<Latitude>(.*)</Latitude><Longitude>(.*)</Longitude>!U', $_result, $_match);
     
                        $_coords['lon'] = $_match[2];
                        $_coords['lat'] = $_match[1];
     
                    }
     
                    break;
            }         
     
            return $_coords;       
        }
     
     
     
        /**
         * fetch a URL. Override this method to change the way URLs are fetched.
         * 
         * @param string $url
         */
        function fetchURL($url) {
     
            return file_get_contents($url);
     
        }
     
        /**
         * get distance between to geocoords using great circle distance formula
         * 
         * @param float $lat1
         * @param float $lat2
         * @param float $lon1
         * @param float $lon2
         * @param float $unit   M=miles, K=kilometers, N=nautical miles, I=inches, F=feet
         */
        function geoGetDistance($lat1,$lon1,$lat2,$lon2,$unit='M') {
     
          // calculate miles
          $M =  69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2)))); 
     
          switch(strtoupper($unit))
          {
            case 'K':
              // kilometers
              return $M * 1.609344;
              break;
            case 'N':
              // nautical miles
              return $M * 0.868976242;
              break;
            case 'F':
              // feet
              return $M * 5280;
              break;            
            case 'I':
              // inches
              return $M * 63360;
              break;            
            case 'M':
            default:
              // miles
              return $M;
              break;
          }
     
        }    
     
    }
     
     
    //***********************************************************************//
    /* Connexion à la base de données */
    require_once("/home/annonces/www/nego/include/config.php");
    require_once("/home/annonces/www/nego/include/functions.php");
    $canif_link = bdd_connect2($dbhost1, $dblogin1, $dbpass1, $dbname1);
    $annonces_link = bdd_connect2($dbhost, $dblogin, $dbpass, $dbname);
    //***********************************************************************//
     
    $map = new GoogleMapAPI('map','tutoriel_map');
     
    $url=$_SERVER['HTTP_HOST'];
    $query = "SELECT cle from cles_gmap where site=\"$url\"";
    //echo $query;						 
    $requete_cle=sql_query2($annonces_link,$query)or die(mysql_error());   
    while($resultat_cle=mysql_fetch_assoc($requete_cle)){ 
    	$clef = $resultat_cle['cle'];   
    } 
    $map->setAPIKey($clef); 
    //taille de la map
    $map->setHeight("300");
    $map->setWidth("430");
    //on desactive la barre de coté?
    $map->disableSidebar();
    //Active les  boutons(map/satellite/hybrid).
    $map->enableTypeControls();
    //Quel est le type de carte par defaut ? (map/satellite/hybrid)
    $map->setMapType('map'); // default
    //On déssactive le formulaire dans l'infobulle pour afficher la direction d'un point a l'autre
    $map->disableDirections();
    // Permet de definir le zoom automatiquement afin de voir tous les marqueurs d'un coup.
    $map->enableZoomEncompass();
    //Active la mini map en bas a droite
    $map->disableOverviewControl();       
    //permet de définir l'icone sur la map, nous on change pas
    $map->setMarkerIcon('http://www.annonces-immobilier-notaires.com/nego/carte-googlemap/house.png','http://www.annonces-immobilier-notaires.com/nego/carte-googlemap/marker_cw_shadow.png',3,10,10,1);
    // http://gifs.toutimages.com/images/fleches/fleche_033.gif
    // http://gifs.toutimages.com/images/fleches/fleche_122.gif
    //permet le mouseover pour un marker
    $map->setInfoWindowTrigger('mouseover');
     
    if (strlen($cp)==5) { $dep = substr($cp, 0, 2); } else if (strlen($cp)==4) { $dep = "0".substr($cp, 0, 1); }
     
    $query = "SELECT * FROM vtiger_account INNER JOIN vtiger_accountscf ON vtiger_account.accountid = vtiger_accountscf.accountid INNER JOIN vtiger_accountbillads ON vtiger_account.accountid=vtiger_accountbillads.accountaddressid WHERE cf_450 = '$crpcen' GROUP BY vtiger_account.accountid";
    //echo $query;
    $result = sql_query2($canif_link, $query) or die(sql_error2());
    if (mysql_num_rows($result)>0) {
    	$donnees2 = mysql_fetch_assoc($result);
    	$adresse = $donnees2['bill_street'];
    	$cp = $donnees2['bill_code'];
    }
     
    $vil = "";
    if ($crpcen!="31087") {
    	$vil .= utf8_encode($adresse).", ";
    }
    $vil .= str_replace(" CEDEX", "", $ville);
    $vil .= ", " .$cp;
    $vil2 = str_replace(Chr(13), " ", $vil);
    $vil2 = str_replace(Chr(10), " ", $vil2);
    //$vil = $cp . " " . str_replace(" CEDEX", "", $ville);
    //echo $vil;
    $map->addMarkerByAddress($vil,'',"<font color=\"black\">".$vil2."</font>");
    //echo "<font color=\"black\">".$cp . " " . $ville."</font>";
     
    ?>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
     
    <html>
     
    <head>
    <title>Google maps</title>
    <?php $map->printHeaderJS(); ?>
    <?php $map->printMapJS(); ?>
     
     
    <!-- necessaire pour google pour tracer les polylines -->
    <style type="text/css">
      v\:* {
        behavior:url(#default#VML);
      }
      /*pour les infobulles de la carte*/
      #gmapmarker { 
        font: normal small verdana, arial, helvetica, sans-serif;
        font-size: 10pt;
        margin: 0px;
        width: 200px;
        height: 50px;
     
      }
      #gmapmarker p{ 
        margin : 0;
        padding : 2px 0 2px 0;
      }
     
      #gmapmarker a {text-decoration: none; color: #00AA00; background-color: transparent;}
     
      #gmapmarker a:hover {color: #F60; background-color: transparent;}
     
      #gmapmarker h1 {
        font-weight: bold; 
        font-size: 13px; 
        color: #250; :/*369*/
        border-bottom: 2px solid #369; /*369*/
        padding : 2px;
        margin : 0;
      }
     
     /*div qui contient la carte*/
      #map {
        float : left;
     
       /* background:#FF0000 url(loading.jpg) repeat;*/
       /* background-color : green; */
      }
     
     
    </style>
     
    </head>
    <body onload="onLoad()"> 
     
      <table><tr><td align="center">
      <?php $map->printMap(); //on affiche la map ?>
     
      <?php $map->printSidebar(); //on affiche la barre de nav?>
      </td></tr></table></center>
    $vil affiche bien une adresse valide... merci encore pour votre aide

  2. #2
    Membre du Club
    Inscrit en
    mai 2005
    Messages
    181
    Détails du profil
    Informations forums :
    Inscription : mai 2005
    Messages : 181
    Points : 45
    Points
    45

    Par défaut

    Bizarre, ça remarche !
    Vous savez pourquoi la carte a été grisée pendant quelques jours ?

Liens sociaux

Règles de messages

  • Vous ne pouvez pas créer de nouvelles discussions
  • Vous ne pouvez pas envoyer des réponses
  • Vous ne pouvez pas envoyer des pièces jointes
  • Vous ne pouvez pas modifier vos messages
  •