/var/www/(Del)hsihk.com/wp-content/themes/flatsome/inc/shortcodes/google_maps.php


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
<?php
// [map]
function shortcode_map($atts$content=null$code) {

    
$mapsrandomid rand();
    
extract(shortcode_atts(array(
        
'lat'  => '',
    
'long' => '',
    
'height' => '400px',
        
'color' => '#58728a',
    
'zoom' => '17',
    
'controls' => 'false',
    
'pan' => 'false',
    ), 
$atts));
    
ob_start();
    
?> 
    
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
    
    function initialize() {
        var styles = {
            'flatsome':  [{
            "featureType": "administrative",
            "stylers": [
              { "visibility": "on" }
            ]
          },
          {
            "featureType": "road",
            "stylers": [
              { "visibility": "on" },
              { "hue": "<?php echo $color ?>" }
            ]
          },
          {
            "stylers": [
              { "visibility": "on" },
              { "hue": "<?php echo $color ?>" },
              { "saturation": -30 }
            ]
          }
        ]};
        
        var myLatlng = new google.maps.LatLng(<?php echo $lat ?><?php echo $long ?>);
        var myOptions = {
            zoom: <?php echo $zoom ?>,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            disableDefaultUI: true,
            mapTypeId: 'flatsome',
            draggable: true,
            zoomControl: false,
                  panControl: false,
                  mapTypeControl: false,
                  scaleControl: false,
                  streetViewControl: false,
                  overviewMapControl: false,
            scrollwheel: false,
            disableDoubleClickZoom: true
        }
        var map = new google.maps.Map(document.getElementById("<?php echo $mapsrandomid?>"), myOptions);
        var styledMapType = new google.maps.StyledMapType(styles['flatsome'], {name: 'flatsome'});
        map.mapTypes.set('flatsome', styledMapType);
        
        var marker = new google.maps.Marker({
            position: myLatlng, 
            map: map,
            title:""
        });   
    }
    
    google.maps.event.addDomListener(window, 'load', initialize);
    google.maps.event.addDomListener(window, 'resize', initialize);
    
    </script>
    
    <div id="map_container">
        <div id="<?php echo $mapsrandomid?>" style="height:<?php echo $height ?>;"></div>
        <div id="map_overlay_top"></div>
        <div id="map_overlay_bottom"></div>
         <?php if($content) {?>
         <div class="map-info">
            <div class="row">
            <div class="large-4 columns right">
                <div class="map_inner">
                <?php echo fixShortcode($content); ?>
              </div> <!-- map_inner -->
            </div><!-- large-4 -->
             </div><!-- row -->
        </div><!-- .map-info -->
       <?php }?>
    </div>

    <?php
    $content 
ob_get_contents();
    
ob_end_clean();
    return 
$content;
}

add_shortcode('map''shortcode_map');