/**
 * Render polyline edit JS
 *
 * @todo  This needs to be converted to a native JS file with localized variables
 * 
 * @param  integer $mapid       Map ID
 * @param  integer $polyid      Polygon ID
 * 
 * @return void
 */
function wpgmaps_b_admin_edit_polyline_javascript($mapid, $polyid)
{
    $res = wpgmza_get_map_data($mapid);
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    $wpgmza_lat = $res->map_start_lat;
    $wpgmza_lng = $res->map_start_lng;
    $wpgmza_map_type = $res->type;
    $wpgmza_width = $res->map_width;
    $wpgmza_height = $res->map_height;
    $wpgmza_width_type = $res->map_width_type;
    $wpgmza_height_type = $res->map_height_type;
    if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") {
        $wpgmza_map_type = "ROADMAP";
    } else {
        if ($wpgmza_map_type == "2") {
            $wpgmza_map_type = "SATELLITE";
        } else {
            if ($wpgmza_map_type == "3") {
                $wpgmza_map_type = "HYBRID";
            } else {
                if ($wpgmza_map_type == "4") {
                    $wpgmza_map_type = "TERRAIN";
                } else {
                    $wpgmza_map_type = "ROADMAP";
                }
            }
        }
    }
    $start_zoom = $res->map_start_zoom;
    if ($start_zoom < 1 || !$start_zoom) {
        $start_zoom = 5;
    }
    if (isset($res->kml)) {
        $kml = $res->kml;
    } else {
        $kml = false;
    }
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    $poly_array = wpgmza_b_return_polyline_array($polyid);
    $polyoptions = wpgmza_b_return_polyline_options($polyid);
    $linecolor = $polyoptions->linecolor;
    $linethickness = $polyoptions->linethickness;
    $fillopacity = $polyoptions->opacity;
    if (!$linecolor) {
        $linecolor = "000000";
    }
    if (!$linethickness) {
        $linethickness = "4";
    }
    if (!$fillopacity) {
        $fillopacity = "0.5";
    }
    $linecolor = "#" . $linecolor;
    if (isset($wpgmza_settings['wpgmza_api_version']) && $wpgmza_settings['wpgmza_api_version'] != "") {
        $api_version_string = "v=" . $wpgmza_settings['wpgmza_api_version'] . "&";
    } else {
        $api_version_string = "v=3.exp&";
    }
    ?>
        <?php 
    if (get_option('wpgmza_google_maps_api_key')) {
        ?>
            <script type="text/javascript">
                var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
                var wpgmza_api_key = '<?php 
        echo get_option('wpgmza_google_maps_api_key');
        ?>
';
                document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?<?php 
        echo $api_version_string;
        ?>
key="+wpgmza_api_key+"' type='text/javascript'%3E%3C/script%3E"));
            </script>
        <?php 
    } else {
        ?>
            <script type="text/javascript">
                var wpgmza_temp_api_key = "<?php 
        echo get_option('wpgmza_temp_api');
        ?>
";
                var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
                document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?<?php 
        echo $api_version_string;
        ?>
key="+wpgmza_temp_api_key+"&libraries=places' type='text/javascript'%3E%3C/script%3E"));
            </script>
        <?php 
    }
    ?>
        <link rel='stylesheet' id='wpgooglemaps-css'  href='<?php 
    echo wpgmaps_get_plugin_url();
    ?>
/css/wpgmza_style.css' type='text/css' media='all' />
        <script type="text/javascript" >
             // polygons variables
            var poly;
            var poly_markers = [];
            var poly_path = new google.maps.MVCArray;
            var path;
                
            jQuery(document).ready(function(){
                
                    function wpgmza_InitMap() {
                        var myLatLng = new google.maps.LatLng(<?php 
    echo $wpgmza_lat;
    ?>
,<?php 
    echo $wpgmza_lng;
    ?>
);
                        MYMAP.init('#wpgmza_map', myLatLng, <?php 
    echo $start_zoom;
    ?>
);
                    }
                    jQuery("#wpgmza_map").css({
                        height:'<?php 
    echo $wpgmza_height;
    echo $wpgmza_height_type;
    ?>
',
                        width:'<?php 
    echo $wpgmza_width;
    echo $wpgmza_width_type;
    ?>
'
                    });
                    wpgmza_InitMap();
                    
                    
                    jQuery("#poly_line").focusout(function() {
                        poly.setOptions({ strokeColor: "#"+jQuery("#poly_line").val() }); 
                    });
                    jQuery("#poly_opacity").keyup(function() {
                        poly.setOptions({ strokeOpacity: jQuery("#poly_opacity").val() }); 
                    });
                    jQuery("#poly_thickness").keyup(function() {
                        poly.setOptions({ strokeWeight: jQuery("#poly_thickness").val() }); 
                    });
            });
            

            var MYMAP = {
                map: null,
                bounds: null
            }
            MYMAP.init = function(selector, latLng, zoom) {
                  var myOptions = {
                    zoom:zoom,
                    center: latLng,
                    zoomControl: true,
                    panControl: true,
                    mapTypeControl: true,
                    streetViewControl: true,
                    mapTypeId: google.maps.MapTypeId.<?php 
    echo $wpgmza_map_type;
    ?>
                  }
                this.map = new google.maps.Map(jQuery(selector)[0], myOptions);
                this.bounds = new google.maps.LatLngBounds();
                // polygons
                
                
                
                poly = new google.maps.Polyline({
                    strokeWeight: "<?php 
    echo $linethickness;
    ?>
",
                    strokeColor: "<?php 
    echo $linecolor;
    ?>
",
                    strokeOpacity: "<?php 
    echo $fillopacity;
    ?>
"
                });
                path = poly.getPath();

                <?php 
    /* polylines */
    $total_polyline_array = wpgmza_b_return_polyline_id_array(sanitize_text_field($_GET['map_id']));
    if ($total_polyline_array > 0) {
        foreach ($total_polyline_array as $poly_id) {
            $polyoptions = wpgmza_b_return_polyline_options($poly_id);
            $linecolor = $polyoptions->linecolor;
            $fillopacity = $polyoptions->opacity;
            $linethickness = $polyoptions->linethickness;
            if (!$linecolor) {
                $linecolor = "000000";
            }
            if (!$linethickness) {
                $linethickness = "4";
            }
            if (!$fillopacity) {
                $fillopacity = "0.5";
            }
            $linecolor = "#" . $linecolor;
            $poly_array = wpgmza_b_return_polyline_array($poly_id);
            ?>
                    
                    <?php 
            if (sizeof($poly_array) > 1) {
                if ($poly_id != $polyid) {
                    ?>
                        var WPGM_PathLineData_<?php 
                    echo $poly_id;
                    ?>
 = [
                        <?php 
                    $poly_array = wpgmza_b_return_polyline_array($poly_id);
                    foreach ($poly_array as $single_poly) {
                        $poly_data_raw = str_replace(" ", "", $single_poly);
                        $poly_data_raw = explode(",", $poly_data_raw);
                        $lat = $poly_data_raw[0];
                        $lng = $poly_data_raw[1];
                        ?>
                            new google.maps.LatLng(<?php 
                        echo $lat;
                        ?>
, <?php 
                        echo $lng;
                        ?>
),            
                            <?php 
                    }
                    ?>
                    ];
                    var WPGM_PathLine_<?php 
                    echo $poly_id;
                    ?>
 = new google.maps.Polyline({
                      path: WPGM_PathLineData_<?php 
                    echo $poly_id;
                    ?>
,
                      strokeColor: "<?php 
                    echo $linecolor;
                    ?>
",
                      strokeOpacity: "<?php 
                    echo $fillopacity;
                    ?>
",
                      strokeWeight: "<?php 
                    echo $linethickness;
                    ?>
"
                      
                    });

                    WPGM_PathLine_<?php 
                    echo $poly_id;
                    ?>
.setMap(this.map);
                    <?php 
                }
            }
        }
    }
    ?>
 


                <?php 
    if ($kml != false) {
        ?>
                var temp = '<?php 
        echo $kml;
        ?>
';
                arr = temp.split(',');
                arr.forEach(function(entry) {
                    var georssLayer = new google.maps.KmlLayer(entry+'?tstamp=<?php 
        echo time();
        ?>
',{suppressInfoWindows: true, zindex: 0, clickable : false});
                    georssLayer.setMap(MYMAP.map);

                });
                <?php 
    }
    ?>


                addPolyline();
                

            }
            function addPolyline() {
                
                
                
                <?php 
    $poly_array = wpgmza_b_return_polyline_array($polyid);
    $polyoptions = wpgmza_b_return_polyline_options($polyid);
    $linecolor = $polyoptions->linecolor;
    $fillopacity = $polyoptions->opacity;
    if (!$linecolor) {
        $linecolor = "000000";
    }
    if (!$fillopacity) {
        $fillopacity = "0.5";
    }
    $linecolor = "#" . $linecolor;
    foreach ($poly_array as $single_poly) {
        $poly_data_raw = str_replace(" ", "", $single_poly);
        $poly_data_raw = str_replace(")", "", $poly_data_raw);
        $poly_data_raw = str_replace("(", "", $poly_data_raw);
        $poly_data_raw = explode(",", $poly_data_raw);
        $lat = $poly_data_raw[0];
        $lng = $poly_data_raw[1];
        ?>
                    var temp_gps = new google.maps.LatLng(<?php 
        echo $lat;
        ?>
, <?php 
        echo $lng;
        ?>
);
                    addExistingPoint(temp_gps);
                    updatePolyPath(path);
                    
                    
                    
                    <?php 
    }
    ?>
                
                
                poly.setMap(MYMAP.map);
                
                google.maps.event.addListener(MYMAP.map, 'click', addPoint);
            }
            function addExistingPoint(temp_gps) {
                
                
                
                path.push(temp_gps);

                var poly_marker = new google.maps.Marker({
                  position: temp_gps,
                  map: MYMAP.map,
                  draggable: true
                });
                poly_markers.push(poly_marker);
                poly_marker.setTitle("#" + path.length);
                google.maps.event.addListener(poly_marker, 'click', function() {
                      poly_marker.setMap(null);
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      poly_markers.splice(i, 1);
                      path.removeAt(i);
                      updatePolyPath(path);    
                      }
                    );

                    google.maps.event.addListener(poly_marker, 'dragend', function() {
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      path.setAt(i, poly_marker.getPosition());
                      updatePolyPath(path);    
                      }
                    );
            }
            function addPoint(event) {
                
                   var path = poly.getPath();
                    path.push(event.latLng);

                    var poly_marker = new google.maps.Marker({
                      position: event.latLng,
                      map: MYMAP.map,
                      draggable: true
                    });


                    
                    poly_markers.push(poly_marker);
                    poly_marker.setTitle("#" + path.length);

                    google.maps.event.addListener(poly_marker, 'click', function() {
                      poly_marker.setMap(null);
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      poly_markers.splice(i, 1);
                      path.removeAt(i);
                      updatePolyPath(path);    
                      }
                    );

                    google.maps.event.addListener(poly_marker, 'dragend', function() {
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      path.setAt(i, poly_marker.getPosition());
                      updatePolyPath(path);    
                      }
                    );
                        
                        
                    updatePolyPath(path);    
              }
              
              function updatePolyPath(poly_path) {
                var temp_array;
                temp_array = "";
                path.forEach(function(latLng, index) { 
//                  temp_array = temp_array + " ["+ index +"] => "+ latLng + ", ";
                  temp_array = temp_array + latLng + ",";
                }); 
                jQuery("#poly_line_list").html(temp_array);
              }            
             

        </script>
        <?php 
}
Exemple #2
0
function wpgmza_return_marker_list($map_id, $admin = true, $width = "100%", $mashup = false, $mashup_ids = false)
{
    global $wpdb;
    global $wpgmza_tblname;
    if ($mashup) {
        // map mashup
        $map_ids = $mashup_ids;
        $wpgmza_cnt = 0;
        if ($mashup_ids[0] == "ALL") {
            $wpgmza_sql1 = "\r\n            SELECT *\r\n            FROM {$wpgmza_tblname}\r\n            ORDER BY `id` DESC\r\n            ";
        } else {
            $wpgmza_id_cnt = count($map_ids);
            $sql_string1 = "";
            foreach ($map_ids as $wpgmza_map_id) {
                $wpgmza_cnt++;
                if ($wpgmza_cnt == 1) {
                    $sql_string1 .= "`map_id` = '{$wpgmza_map_id}' ";
                } elseif ($wpgmza_cnt > 1 && $wpgmza_cnt < $wpgmza_id_cnt) {
                    $sql_string1 .= "OR `map_id` = '{$wpgmza_map_id}' ";
                } else {
                    $sql_string1 .= "OR `map_id` = '{$wpgmza_map_id}' ";
                }
            }
            $wpgmza_sql1 = "\r\n            SELECT *\r\n            FROM {$wpgmza_tblname}\r\n            WHERE {$sql_string1} ORDER BY `id` DESC\r\n            ";
        }
    } else {
        $wpgmza_sql1 = "\r\n            SELECT *\r\n            FROM {$wpgmza_tblname}\r\n            WHERE `map_id` = '{$map_id}' ORDER BY `id` DESC\r\n            ";
    }
    $marker_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpgmza_tblname} WHERE map_id = %d", $map_id));
    if ($marker_count > 2000) {
        return __("There are too many markers to make use of the live edit function. The maximum amount for this functionality is 2000 markers. Anything more than that could crash your browser. In order to edit your markers, you would need to download the table in CSV format, edit it and re-upload it.", "wp-google-maps");
    } else {
        $results = $wpdb->get_results($wpgmza_sql1);
        $wpgmza_tmp_body = "";
        $wpgmza_tmp_head = "";
        $wpgmza_tmp_footer = "";
        $res = wpgmza_get_map_data($map_id);
        if (!$res->default_marker) {
            $default_marker = "<img src='" . wpgmaps_get_plugin_url() . "/images/marker.png' />";
        } else {
            $default_marker = "<img src='" . $res->default_marker . "' />";
        }
        foreach ($results as $result) {
            $img = $result->pic;
            $link = $result->link;
            $icon = $result->icon;
            if (isset($result->approved)) {
                $approved = $result->approved;
                if ($approved == 0) {
                    $show_approval_button = true;
                } else {
                    $show_approval_button = false;
                }
            } else {
                $show_approval_button = false;
            }
            $category_icon = wpgmza_get_category_icon($result->category);
            if (!$img) {
                $pic = "";
            } else {
                $pic = "<img src=\"" . $result->pic . "\" width=\"40\" />";
            }
            if (!$category_icon) {
                if (!$icon) {
                    $icon = $default_marker;
                } else {
                    $icon = "<img src='" . $result->icon . "' />";
                }
            } else {
                if (!$icon) {
                    $icon = "<img src='" . $category_icon . "' />";
                } else {
                    $icon = "<img src='" . $result->icon . "' />";
                }
            }
            if (!$link) {
                $linktd = "";
            } else {
                $linktd = "<a href=\"" . $result->link . "\" target=\"_BLANK\" title=\"" . __("View this link", "wp-google-maps") . "\">&gt;&gt;</a>";
            }
            if ($admin) {
                $wpgmza_tmp_body .= "<tr id=\"wpgmza_tr_" . $result->id . "\" class=\"gradeU\">";
                $wpgmza_tmp_body .= "<td height=\"40\">" . $result->id . "</td>";
                $wpgmza_tmp_body .= "<td height=\"40\">" . $icon . "<input type=\"hidden\" id=\"wpgmza_hid_marker_icon_" . $result->id . "\" value=\"" . $result->icon . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_anim_" . $result->id . "\" value=\"" . $result->anim . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_category_" . $result->id . "\" value=\"" . $result->category . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_infoopen_" . $result->id . "\" value=\"" . $result->infoopen . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_retina_" . $result->id . "\" value=\"" . $result->retina . "\" /></td>";
                $wpgmza_tmp_body .= "<td>" . stripslashes($result->title) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_title_" . $result->id . "\" value=\"" . stripslashes($result->title) . "\" /></td>";
                $wpgmza_tmp_body .= "<td>" . wpgmza_return_category_name($result->category) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_category_" . $result->id . "\" value=\"" . $result->category . "\" /></td>";
                $wpgmza_tmp_body .= "<td>" . stripslashes($result->address) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_address_" . $result->id . "\" value=\"" . stripslashes($result->address) . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_lat_" . $result->id . "\" value=\"" . $result->lat . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_lng_" . $result->id . "\" value=\"" . $result->lng . "\" /></td>";
                $wpgmza_tmp_body .= "<td>" . stripslashes($result->description) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_desc_" . $result->id . "\" value=\"" . htmlspecialchars(stripslashes($result->description)) . "\" /></td>";
                $wpgmza_tmp_body .= "<td>{$pic}<input type=\"hidden\" id=\"wpgmza_hid_marker_pic_" . $result->id . "\" value=\"" . $result->pic . "\" /></td>";
                $wpgmza_tmp_body .= "<td>{$linktd}<input type=\"hidden\" id=\"wpgmza_hid_marker_link_" . $result->id . "\" value=\"" . $result->link . "\" /></td>";
                $wpgmza_tmp_body .= "<td width='170' align='center'>";
                $wpgmza_tmp_body .= "    <a href=\"#wpgmaps_marker\" title=\"" . __("Edit this marker", "wp-google-maps") . "\" class=\"wpgmza_edit_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-edit\"> </i> </a> ";
                $wpgmza_tmp_body .= "    <a href=\"?page=wp-google-maps-menu&action=edit_marker&id=" . $result->id . "\" title=\"" . __("Edit this marker", "wp-google-maps") . "\" class=\"wpgmza_edit_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-map-marker\"> </i></a> ";
                if ($show_approval_button) {
                    $wpgmza_tmp_body .= "    <a href=\"javascript:void(0);\" title=\"" . __("Approve this marker", "wp-google-maps") . "\" class=\"wpgmza_approve_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-check\"> </i> </a> ";
                }
                $wpgmza_tmp_body .= "    <a href=\"javascript:void(0);\" title=\"" . __("Delete this marker", "wp-google-maps") . "\" class=\"wpgmza_del_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-times\"> </i></a>";
                $wpgmza_tmp_body .= "</td>";
                $wpgmza_tmp_body .= "</tr>";
            } else {
                $wpgmza_tmp_body .= "<tr id=\"wpgmza_marker_" . $result->id . "\" mid=\"" . $result->id . "\" mapid=\"" . $result->map_id . "\" class=\"wpgmaps_mlist_row\">";
                $wpgmza_tmp_body .= "   <td width='1px;' style='display:none; width:1px !important;'><span style='display:none;'>" . sprintf('%02d', $result->id) . "</span></td>";
                $wpgmza_tmp_body .= "   <td class='wpgmza_table_marker' height=\"40\">" . str_replace("'", "\"", $icon) . "</td>";
                $wpgmza_tmp_body .= "   <td class='wpgmza_table_title'>" . stripslashes($result->title) . "</td>";
                $wpgmza_tmp_body .= "   <td class='wpgmza_table_category'>" . wpgmza_return_category_name($result->category) . "</td>";
                $wpgmza_tmp_body .= "   <td class='wpgmza_table_address'>" . stripslashes($result->address) . "</td>";
                $wpgmza_tmp_body .= "   <td class='wpgmza_table_description'>" . stripslashes($result->description) . "</td>";
                $wpgmza_tmp_body .= "</tr>";
            }
        }
        if ($admin) {
            $wpgmza_tmp_head .= "<table id=\"wpgmza_table\" class=\"display\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:{$width};\">";
            $wpgmza_tmp_head .= "<thead>";
            $wpgmza_tmp_head .= "<tr>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("ID", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("Icon", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("Title", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("Category", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("Address", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("Description", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("Image", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th><strong>" . __("Link", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th style='width:182px;'><strong>" . __("Action", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "</tr>";
            $wpgmza_tmp_head .= "</thead>";
            $wpgmza_tmp_head .= "<tbody>";
        } else {
            $wpgmza_tmp_head .= "<div id=\"wpgmza_marker_holder_" . $map_id . "\" style=\"width:{$width};\">";
            $wpgmza_tmp_head .= "<table id=\"wpgmza_table_" . $map_id . "\" class=\"wpgmza_table\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:{$width};\">";
            $wpgmza_tmp_head .= "<thead>";
            $wpgmza_tmp_head .= "<tr>";
            $wpgmza_tmp_head .= "   <th width='1' style='display:none; width:1px !important;'></th>";
            $wpgmza_tmp_head .= "   <th class='wpgmza_table_marker'><strong></strong></th>";
            $wpgmza_tmp_head .= "   <th class='wpgmza_table_title'><strong>" . __("Title", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th class='wpgmza_table_category'><strong>" . __("Category", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th class='wpgmza_table_address'><strong>" . __("Address", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "   <th class='wpgmza_table_description'><strong>" . __("Description", "wp-google-maps") . "</strong></th>";
            $wpgmza_tmp_head .= "</tr>";
            $wpgmza_tmp_head .= "</thead>";
            $wpgmza_tmp_head .= "<tbody>";
        }
        if ($admin) {
            $wpgmza_tmp_footer .= "</tbody></table>";
        } else {
            $wpgmza_tmp_footer .= "</tbody></table></div>";
        }
        return $wpgmza_tmp_head . $wpgmza_tmp_body . $wpgmza_tmp_footer;
    }
}
 function list_markers($admin = false, $type = 1, $map_id = false, $category_data = false, $mashup = false, $mashup_ids = false, $marker_array = false, $order_by = false, $order = false, $include_mlist_div = true)
 {
     global $wpdb;
     global $wpgmza_tblname;
     $res = $this->get_map_data($map_id);
     if ($type == 4) {
         $additional_img_class = "wpgmza_small_img";
     } else {
         $additional_img_class = "";
     }
     if (!isset($res->default_marker) || !$res->default_marker) {
         $default_marker = "<img src='" . wpgmaps_get_plugin_url() . "/images/marker.png'  style='' class='{$additional_img_class}' />";
     } else {
         $default_marker = "<img src='" . $res->default_marker . "' style='' class='{$additional_img_class}' />";
     }
     $width = stripslashes(trim($res->map_width)) . stripslashes(trim($res->map_width_type));
     // marker sorting functionality
     if ($res->order_markers_by == '1') {
         $order_by = "id";
     } else {
         if ($res->order_markers_by == '2') {
             $order_by = "title";
         } else {
             if ($res->order_markers_by == '3') {
                 $order_by = "address";
             } else {
                 if ($res->order_markers_by == '4') {
                     $order_by = "description";
                 } else {
                     if ($res->order_markers_by == '5') {
                         $order_by = "category";
                     } else {
                         $order_by = "id";
                     }
                 }
             }
         }
     }
     if ($res->order_markers_choice == '1') {
         $order_choice = "ASC";
     } else {
         $order_choice = "DESC";
     }
     if ($mashup) {
         // map mashup
         $map_ids = $mashup_ids;
         $wpgmza_cnt = 0;
         if ($mashup_ids[0] == "ALL") {
             $wpgmza_sql1 = "\r\n                SELECT *\r\n                FROM {$wpgmza_tblname}\r\n                ORDER BY `id` DESC\r\n                ";
         } else {
             $wpgmza_id_cnt = count($map_ids);
             $sql_string1 = "";
             foreach ($map_ids as $wpgmza_map_id) {
                 $wpgmza_cnt++;
                 if ($wpgmza_cnt == 1) {
                     $sql_string1 .= "`map_id` = '{$wpgmza_map_id}' ";
                 } elseif ($wpgmza_cnt > 1 && $wpgmza_cnt < $wpgmza_id_cnt) {
                     $sql_string1 .= "OR `map_id` = '{$wpgmza_map_id}' ";
                 } else {
                     $sql_string1 .= "OR `map_id` = '{$wpgmza_map_id}' ";
                 }
             }
             $wpgmza_sql1 = "\r\n                SELECT *\r\n                FROM {$wpgmza_tblname}\r\n                WHERE {$sql_string1} ORDER BY `id` DESC\r\n                ";
         }
     } else {
         if ($order_by && $order_choice) {
             $wpgmza_sql1 = "\r\n                SELECT *\r\n                FROM {$wpgmza_tblname}\r\n                WHERE `map_id` = '{$map_id}' AND `approved` = 1 ORDER BY `{$order_by}` {$order_choice}\r\n                ";
         } else {
             $wpgmza_sql1 = "\r\n                SELECT *\r\n                FROM {$wpgmza_tblname}\r\n                WHERE `map_id` = '{$map_id}' AND `approved` = 1 ORDER BY `id` DESC\r\n                ";
         }
     }
     $marker_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpgmza_tblname} WHERE map_id = %d", $map_id));
     //        removed in 5.49 as it was showing up in the front end.
     //        =========================================================
     //        if ($marker_count > 5000) {
     //            return __("There are too many markers to make use of the live edit function. The maximum amount for this functionality is 2000 markers. Anything more than that could crash your browser. In order to edit your markers, you would need to download the table in CSV format, edit it and re-upload it.","wp-google-maps");
     //        } else {
     //
     //        }
     $results = $wpdb->get_results($wpgmza_sql1);
     $wpgmza_tmp_body = "";
     $wpgmza_tmp_head = "";
     $wpgmza_tmp_footer = "";
     $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
     if (isset($wpgmza_settings['wpgmza_settings_image_resizing']) && $wpgmza_settings['wpgmza_settings_image_resizing'] == 'yes') {
         $wpgmza_image_resizing = true;
     } else {
         $wpgmza_image_resizing = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_image_height'])) {
         $wpgmza_image_height = $wpgmza_settings['wpgmza_settings_image_height'];
     } else {
         $wpgmza_image_height = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_image_width'])) {
         $wpgmza_image_width = $wpgmza_settings['wpgmza_settings_image_width'];
     } else {
         $wpgmza_image_width = false;
     }
     if (!$wpgmza_image_height || !isset($wpgmza_image_height)) {
         $wpgmza_image_height = "100";
     }
     if (!$wpgmza_image_width || !isset($wpgmza_image_width)) {
         $wpgmza_image_width = "100";
     }
     if (isset($res->directions_enabled)) {
         $d_enabled = $res->directions_enabled;
     } else {
         $d_enabled = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_image']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_image'] == "yes") {
         $carousel_show_image = false;
     } else {
         $carousel_show_image = true;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_icon']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_icon'] == "yes") {
         $carousel_show_icon = false;
     } else {
         $carousel_show_icon = true;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_title']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_title'] == "yes") {
         $carousel_show_title = false;
     } else {
         $carousel_show_title = true;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_description']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_description'] == "yes") {
         $carousel_show_description = false;
     } else {
         $carousel_show_description = true;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_address']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_address'] == "yes") {
         $carousel_show_address = false;
     } else {
         $carousel_show_address = true;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_directions']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_directions'] == "yes") {
         $carousel_show_directions = false;
     } else {
         $carousel_show_directions = true;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_marker_link']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_marker_link'] == "yes") {
         $carousel_show_link = false;
     } else {
         $carousel_show_link = true;
     }
     if (isset($wpgmza_settings['wpgmza_settings_carousel_markerlist_resize_image']) && $wpgmza_settings['wpgmza_settings_carousel_markerlist_resize_image'] == "yes") {
         $carousel_resize_image = true;
     } else {
         $carousel_resize_image = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_markerlist_category'])) {
         $hide_category_column = $wpgmza_settings['wpgmza_settings_markerlist_category'];
     } else {
         $hide_category_column = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_markerlist_icon'])) {
         $hide_icon_column = $wpgmza_settings['wpgmza_settings_markerlist_icon'];
     } else {
         $hide_icon_column = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_markerlist_title'])) {
         $hide_title_column = $wpgmza_settings['wpgmza_settings_markerlist_title'];
     } else {
         $hide_title_column = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_markerlist_address'])) {
         $hide_address_column = $wpgmza_settings['wpgmza_settings_markerlist_address'];
     } else {
         $hide_address_column = false;
     }
     if (isset($wpgmza_settings['wpgmza_settings_markerlist_description'])) {
         $hide_description_column = $wpgmza_settings['wpgmza_settings_markerlist_description'];
     } else {
         $hide_description_column = false;
     }
     $wmcnt = 0;
     foreach ($results as $result) {
         /* this handles the ajax data requests for the store locator */
         if (is_array($marker_array)) {
             $display = 0;
             foreach ($marker_array as $marker) {
                 if ($marker == $result->id) {
                     $display++;
                 }
             }
         } else {
             $display = 1;
             /* show all markers as we havent passed through any marker variables to check */
         }
         $c_display = 0;
         /* this handles the ajax data requests for the category filtering */
         $marker_category = $result->category;
         $marker_category_data = explode(",", $marker_category);
         if ($category_data == 'all' || !$category_data) {
             $c_display++;
         } else {
             /* checkbox method */
             if (is_array($category_data)) {
                 $c_display = 0;
                 foreach ($category_data as $cat) {
                     foreach ($marker_category_data as $marker_cat) {
                         if ($marker_cat == $cat) {
                             $c_display++;
                         }
                     }
                 }
             } else {
                 /* select method */
                 $c_display = 0;
                 foreach ($marker_category_data as $marker_cat) {
                     if ($marker_cat == $category_data) {
                         $c_display++;
                     }
                 }
             }
         }
         if ($display > 0 && $c_display > 0) {
             $wmcnt++;
             if ($wmcnt % 2) {
                 $carousel_oddeven = "wpgmza_carousel_odd";
                 $oddeven = "wpgmaps_odd";
             } else {
                 $oddeven = "wpgmaps_even";
                 $carousel_oddeven = "wpgmza_carousel_even";
             }
             $img = $result->pic;
             $link = $result->link;
             $icon = $result->icon;
             if (isset($result->approved)) {
                 $approved = $result->approved;
                 if ($approved == 0) {
                     $show_approval_button = true;
                 } else {
                     $show_approval_button = false;
                 }
             } else {
                 $show_approval_button = false;
             }
             $category_icon = wpgmza_get_category_icon($result->category);
             if (!$category_icon) {
                 if (!$icon) {
                     $icon = $default_marker;
                 } else {
                     $icon = "<img class=\"wpgmza_marker_icon {$additional_img_class}\" src='" . $result->icon . "' style='margin: 5px auto;' />";
                 }
             } else {
                 if (!$icon) {
                     $icon = "<img class=\"wpgmza_marker_icon {$additional_img_class}\" src='" . $category_icon . "' style='margin: 5px auto;' />";
                 } else {
                     $icon = "<img class=\"wpgmza_marker_icon {$additional_img_class}\" src='" . $result->icon . "' style='margin: 5px auto;' />";
                 }
             }
             if (!$link) {
                 $linktd = "";
             } else {
                 $linktd = "<a href=\"" . $result->link . "\" class=\"wpgmza_marker_link\" target=\"_BLANK\" title=\"" . __("View this link", "wp-google-maps") . "\">&gt;&gt;</a>";
             }
             if ($admin) {
                 $wpgmza_tmp_body .= "<tr id=\"wpgmza_tr_" . $result->id . "\" class=\"gradeU\">";
                 $wpgmza_tmp_body .= "<td height=\"40\">" . $result->id . "</td>";
                 $wpgmza_tmp_body .= "<td height=\"40\">" . $icon . "<input type=\"hidden\" id=\"wpgmza_hid_marker_icon_" . $result->id . "\" value=\"" . $result->icon . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_anim_" . $result->id . "\" value=\"" . $result->anim . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_category_" . $result->id . "\" value=\"" . $result->category . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_infoopen_" . $result->id . "\" value=\"" . $result->infoopen . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_retina_" . $result->id . "\" value=\"" . $result->retina . "\" /></td>";
                 $wpgmza_tmp_body .= "<td>" . stripslashes($result->title) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_title_" . $result->id . "\" value=\"" . stripslashes($result->title) . "\" /></td>";
                 $wpgmza_tmp_body .= "<td>" . stripslashes(wpgmza_return_category_name($result->category)) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_category_" . $result->id . "\" value=\"" . $result->category . "\" /></td>";
                 $wpgmza_tmp_body .= "<td>" . stripslashes($result->address) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_address_" . $result->id . "\" value=\"" . stripslashes($result->address) . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_lat_" . $result->id . "\" value=\"" . $result->lat . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_lng_" . $result->id . "\" value=\"" . $result->lng . "\" /></td>";
                 $wpgmza_tmp_body .= "<td>" . stripslashes($result->description) . "<input type=\"hidden\" id=\"wpgmza_hid_marker_desc_" . $result->id . "\" value=\"" . htmlspecialchars(stripslashes($result->description)) . "\" /></td>";
                 $wpgmza_tmp_body .= "<td>{$pic}<input type=\"hidden\" id=\"wpgmza_hid_marker_pic_" . $result->id . "\" value=\"" . $result->pic . "\" /></td>";
                 $wpgmza_tmp_body .= "<td>{$linktd}<input type=\"hidden\" id=\"wpgmza_hid_marker_link_" . $result->id . "\" value=\"" . $result->link . "\" /></td>";
                 $wpgmza_tmp_body .= "<td width='170' align='center'>";
                 $wpgmza_tmp_body .= "    <a href=\"#wpgmaps_marker\" title=\"" . __("Edit this marker", "wp-google-maps") . "\" class=\"wpgmza_edit_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-edit\"> </i> </a> ";
                 $wpgmza_tmp_body .= "    <a href=\"?page=wp-google-maps-menu&action=edit_marker&id=" . $result->id . "\" title=\"" . __("Edit this marker", "wp-google-maps") . "\" class=\"wpgmza_edit_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-map-marker\"> </i></a> ";
                 if ($show_approval_button) {
                     $wpgmza_tmp_body .= "    <a href=\"javascript:void(0);\" title=\"" . __("Approve this marker", "wp-google-maps") . "\" class=\"wpgmza_approve_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-check\"> </i> </a> ";
                 }
                 $wpgmza_tmp_body .= "    <a href=\"javascript:void(0);\" title=\"" . __("Delete this marker", "wp-google-maps") . "\" class=\"wpgmza_del_btn button\" id=\"" . $result->id . "\"><i class=\"fa fa-times\"> </i></a>";
                 $wpgmza_tmp_body .= "</td>";
                 $wpgmza_tmp_body .= "</tr>";
             } else {
                 if ($type == 1) {
                     $img = $result->pic;
                     $wpgmaps_id = $result->id;
                     $link = $result->link;
                     $icon = $result->icon;
                     $wpgmaps_lat = $result->lat;
                     $wpgmaps_lng = $result->lng;
                     $wpgmaps_address = $result->address;
                     if (!$img) {
                         $pic = "<img src='" . plugins_url(plugin_basename(dirname(__FILE__))) . "/images/no-image.jpg' class='wpgmza_map_image' style=\"height:" . $wpgmza_image_height . "px; width:" . $wpgmza_image_width . "px\"\" />";
                     } else {
                         /* added in 5.52 - phasing out timthumb */
                         /* we have phased out timthumb in 5.54
                            if (isset($wpgmza_settings['wpgmza_settings_use_timthumb'])) { $wpgmza_use_timthumb = $wpgmza_settings['wpgmza_settings_use_timthumb']; } else { $wpgmza_use_timthumb = true; }
                                if ($wpgmza_use_timthumb == "" || !isset($wpgmza_use_timthumb) || $wpgmza_use_timthumb == 1) {
                                    $pic = "<img src='".wpgmaps_get_plugin_url()."/timthumb.php?src=".$result->pic."&h=".$wpgmza_image_height."&w=".$wpgmza_image_width."&zc=1' title='' alt='' style=\"\" />";
                                } else  {
                            */
                         if ($wpgmza_image_resizing) {
                             $pic = "<img src='" . $result->pic . "' class='wpgmza_map_image' style=\"height:" . $wpgmza_image_height . "px; width:" . $wpgmza_image_width . "px\" />";
                         } else {
                             $pic = "<img src='" . $result->pic . "' class='wpgmza_map_image' />";
                         }
                         /* } */
                     }
                     if (!$icon) {
                         $icon = $default_marker;
                     } else {
                         $icon = "<img class='{$additional_img_class}' src='" . $result->icon . "' />";
                     }
                     if ($d_enabled == "1") {
                         $wpgmaps_dir_text = "<br /><a href=\"javascript:void(0);\" id=\"" . $map_id . "\" title=\"" . __("Get directions to", "wp-google-maps") . " " . $result->title . "\" class=\"wpgmza_gd\" wpgm_addr_field=\"" . $wpgmaps_address . "\" gps=\"{$wpgmaps_lat},{$wpgmaps_lng}\">" . __("Directions", "wp-google-maps") . "</a>";
                     } else {
                         $wpgmaps_dir_text = "";
                     }
                     if ($result->description) {
                         $wpgmaps_desc_text = "<br />" . $result->description . "";
                     } else {
                         $wpgmaps_desc_text = "";
                     }
                     if ($wmcnt % 2) {
                         $oddeven = "wpgmaps_odd";
                     } else {
                         $oddeven = "wpgmaps_even";
                     }
                     $wpgmza_tmp_body .= "<div id=\"wpgmza_marker_" . $result->id . "\" mid=\"" . $result->id . "\" mapid=\"" . $map_id . "\" class=\"wpgmaps_mlist_row wpgmza_basic_row {$oddeven}\">";
                     $wpgmza_tmp_body .= "<div class='wpgmza-basic-listing-content-holder'>";
                     $wpgmza_tmp_body .= "<div class='wpgmza-basic-listing-image-holder'>{$pic}</div>";
                     $wpgmza_tmp_body .= "";
                     $wpgmza_tmp_body .= "<div class='wpgmza-content-address-holder'>";
                     if (isset($result->title) && $result->title != "") {
                         $wpgmza_tmp_body .= "<p><strong><a href=\"javascript:void(0);\" id=\"wpgmaps_marker_{$wpgmaps_id}\" title=\"" . stripslashes($result->title) . "\">" . stripslashes($result->title) . "</a></strong></p>";
                     }
                     if (isset($hide_icon_column) && $hide_icon_column == "yes") {
                     } else {
                         $wpgmza_tmp_body .= "{$icon}";
                     }
                     if (isset($hide_address_column) && $hide_address_column == "yes") {
                     } else {
                         $wpgmza_tmp_body .= "<div class='wpgmza-address'>";
                         $wpgmza_tmp_body .= "" . stripslashes($result->address);
                         $wpgmza_tmp_body .= "</div>";
                     }
                     if (isset($hide_description_column) && $hide_description_column == "yes") {
                     } else {
                         $wpgmza_tmp_body .= "<div class='wpgmza-desc'>";
                         $wpgmza_tmp_body .= "<p>" . stripslashes($result->description) . "</p>";
                         $wpgmza_tmp_body .= "<p>" . $wpgmaps_dir_text . "</p>";
                         $wpgmza_tmp_body .= "</div>";
                     }
                     $wpgmza_tmp_body .= "</div>";
                     $wpgmza_tmp_body .= "</div>";
                     $wpgmza_tmp_body .= "</div>";
                     /*
                     $wpgmza_tmp_body .= "
                         <tr id=\"wpgmza_marker_".$result->id."\" mid=\"".$result->id."\" mapid=\"".$result->map_id."\" class=\"wpgmaps_mlist_row $oddeven\">
                             <td width=\"40\" class=\"wpgmaps_mlist_marker\">".$icon."</td>
                             <td class=\"wpgmaps_mlist_pic\" style=\"width:".($wpgmza_image_width+20)."px;\">$pic</td>
                             <td  valign=\"top\" align=\"left\" class=\"wpgmaps_mlist_info\">
                                 <strong><a href=\"javascript:openInfoWindow($wpgmaps_id);\" id=\"wpgmaps_marker_$wpgmaps_id\" title=\"".stripslashes($result->title)."\">".stripslashes($result->title)."</a></strong>
                                 ".stripslashes($wpgmaps_desc_text)."
                                 $wpgmaps_dir_text
                             </td>
                     
                         </tr>";
                     */
                 } else {
                     if ($type == 2) {
                         $wpgmza_tmp_body .= "<tr id=\"wpgmza_marker_" . $result->id . "\" mid=\"" . $result->id . "\" mapid=\"" . $map_id . "\" class=\"wpgmaps_mlist_row\">";
                         if (isset($hide_icon_column) && $hide_icon_column == "yes") {
                         } else {
                             $wpgmza_tmp_body .= "   <td class='wpgmza_table_marker' height=\"40\">" . str_replace("'", "\"", $icon) . "</td>";
                         }
                         if (isset($hide_title_column) && $hide_title_column == "yes") {
                         } else {
                             $wpgmza_tmp_body .= "   <td class='wpgmza_table_title'>" . stripslashes($result->title) . "</td>";
                         }
                         if (isset($hide_category_column) && $hide_category_column == "yes") {
                         } else {
                             $wpgmza_tmp_body .= "   <td class='wpgmza_table_category'>" . stripslashes(wpgmza_return_category_name($result->category)) . " </td>";
                         }
                         if (isset($hide_address_column) && $hide_address_column == "yes") {
                         } else {
                             $wpgmza_tmp_body .= "   <td class='wpgmza_table_address'>" . stripslashes($result->address) . "</td>";
                         }
                         if (isset($hide_description_column) && $hide_description_column == "yes") {
                         } else {
                             $wpgmza_tmp_body .= "   <td class='wpgmza_table_description'>" . stripslashes($result->description) . "</td>";
                         }
                         /* deprecated in 5.54
                            $wpgmza_tmp_body .= "   <td width='1px;' style='display:none; width:1px !important;'>".sprintf('%02d', $result->id)."</td>";
                            */
                         $wpgmza_tmp_body .= "</tr>";
                     } else {
                         if ($type == 3) {
                             if (!$img) {
                                 $pic = "";
                             } else {
                                 /* added in 5.52 - phasing out timthumb */
                                 /* we have phased out timthumb in 5.54
                                    if (isset($wpgmza_settings['wpgmza_settings_use_timthumb'])) { $wpgmza_use_timthumb = $wpgmza_settings['wpgmza_settings_use_timthumb']; } else { $wpgmza_use_timthumb = true; }
                                        if ($wpgmza_use_timthumb == "" || !isset($wpgmza_use_timthumb) || $wpgmza_use_timthumb == 1) {
                                            $pic = "<img src='".wpgmaps_get_plugin_url()."/timthumb.php?src=".$result->pic."&h=".$wpgmza_image_height."&w=".$wpgmza_image_width."&zc=1' title='' alt='' style=\"\" />";
                                        } else  {
                                    */
                                 if ($wpgmza_image_resizing) {
                                     $pic = "<img src='" . $result->pic . "' class='wpgmza_map_image' style=\"margin:5px auto; height:" . $wpgmza_image_height . "px; width:" . $wpgmza_image_width . "px\" />";
                                 } else {
                                     $pic = "<img src='" . $result->pic . "' class='wpgmza_map_image' style=\"margin:5px auto;\" />";
                                 }
                                 /* } */
                             }
                             if ($d_enabled == "1") {
                                 $wpgmaps_dir_text = "<p class=\"wpgmza_marker_directions_link\"><a href=\"javascript:void(0);\" id=\"" . $map_id . "\" title=\"" . __("Get directions to", "wp-google-maps") . " " . $result->title . "\" class=\"wpgmza_gd\" wpgm_addr_field=\"" . stripslashes($result->address) . "\" gps=\"" . stripslashes($result->lat) . "," . stripslashes($result->lng) . "\">" . __("Directions", "wp-google-maps") . "</a></p>";
                             } else {
                                 $wpgmaps_dir_text = "";
                             }
                             $wpgmza_tmp_body .= "<div class=\"item wpgmaps_mlist_row {$carousel_oddeven}\" mid=\"" . $result->id . "\" mapid=\"" . $map_id . "\"> ";
                             if ($carousel_show_image) {
                                 $wpgmza_tmp_body .= "   <div class=\"wpgmza_carousel_image_holder\">{$pic}</div>";
                             }
                             if ($carousel_show_icon) {
                                 $wpgmza_tmp_body .= "   <div class=\"wpgmza_carousel_image_holder\">{$icon}</div>";
                             }
                             $wpgmza_tmp_body .= "   <div class=\"wpgmza_carousel_info_holder\">";
                             if ($carousel_show_title) {
                                 $wpgmza_tmp_body .= "   <p class=\"wpgmza_marker_title\">" . stripslashes($result->title) . "</p>";
                             }
                             if ($carousel_show_address) {
                                 $wpgmza_tmp_body .= "   <p class=\"wpgmza_marker_address\">" . stripslashes($result->address) . "</p>";
                             }
                             if ($carousel_show_description) {
                                 $wpgmza_tmp_body .= "   <p class=\"wpgmza_marker_description\">" . stripslashes($result->description) . "</p>";
                             }
                             if ($carousel_show_link) {
                                 $wpgmza_tmp_body .= "   <p class=\"wpgmza_marker_link\">" . stripslashes($result->link) . "</p>";
                             }
                             if ($carousel_show_directions) {
                                 $wpgmza_tmp_body .= "   " . $wpgmaps_dir_text . "";
                             }
                             $wpgmza_tmp_body .= "   </div>";
                             $wpgmza_tmp_body .= "</div>";
                         } else {
                             if ($type == 4) {
                                 $wpgmza_tmp_body .= "<div id=\"wpgmza_marker_" . $result->id . "\" mid=\"" . $result->id . "\" mapid=\"" . $map_id . "\" class=\"wpgmaps_blist_row\">";
                                 if (isset($hide_icon_column) && $hide_icon_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= "   <div class='wpgmza-basic-list-item wpgmza_div_marker' style='max-width: 14px; max-height: 14px;'>" . str_replace("'", "\"", $icon) . "</div>";
                                 }
                                 if (isset($hide_title_column) && $hide_title_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= "   <div class='wpgmza-basic-list-item wpgmza_div_title'> " . stripslashes($result->title) . "</div>";
                                 }
                                 if (isset($hide_address_column) && $hide_address_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= " <div class='wpgmza-basic-list-item wpgmza_div_address'> (" . stripslashes($result->address) . ")</div>";
                                 }
                                 $wpgmza_tmp_body .= "</div>";
                             } else {
                                 $wpgmza_tmp_body .= "<tr id=\"wpgmza_marker_" . $result->id . "\" mid=\"" . $result->id . "\" mapid=\"" . $map_id . "\" class=\"wpgmaps_mlist_row\">";
                                 if (isset($hide_icon_column) && $hide_icon_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= "   <td class='wpgmza_table_marker' height=\"40\">" . str_replace("'", "\"", $icon) . "</td>";
                                 }
                                 if (isset($hide_title_column) && $hide_title_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= "   <td class='wpgmza_table_title'>" . stripslashes($result->title) . "</td>";
                                 }
                                 if (isset($hide_category_column) && $hide_category_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= "   <td class='wpgmza_table_category'>" . stripslashes(wpgmza_return_category_name($result->category)) . " </td>";
                                 }
                                 if (isset($hide_address_column) && $hide_address_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= "   <td class='wpgmza_table_address'>" . stripslashes($result->address) . "</td>";
                                 }
                                 if (isset($hide_description_column) && $hide_description_column == "yes") {
                                 } else {
                                     $wpgmza_tmp_body .= "   <td class='wpgmza_table_description'>" . stripslashes($result->description) . "</td>";
                                 }
                                 $wpgmza_tmp_body .= "   <td width='1px;' style='display:none; width:1px !important;'><span style='display:none;'>" . sprintf('%02d', $result->id) . "</span></td>";
                                 $wpgmza_tmp_body .= "</tr>";
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($admin) {
         $wpgmza_tmp_head .= "<table id=\"wpgmza_table\" class=\"display \" cellspacing=\"0\" cellpadding=\"0\" style=\"width:{$width};\">";
         $wpgmza_tmp_head .= "<thead>";
         $wpgmza_tmp_head .= "<tr>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("ID", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("Icon", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("Title", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("Category", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("Address", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("Description", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("Image", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th><strong>" . __("Link", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "   <th style='width:182px;'><strong>" . __("Action", "wp-google-maps") . "</strong></th>";
         $wpgmza_tmp_head .= "</tr>";
         $wpgmza_tmp_head .= "</thead>";
         $wpgmza_tmp_head .= "<tbody>";
     } else {
         if ($type == 1) {
             $wpgmza_tmp_head .= "<div id=\"wpgmza_marker_list_" . $map_id . "\" class=\"wpgmza_marker_list_class\" style='width:" . $width . ";'>";
         } else {
             if ($type == 2) {
                 /* advanced marker listing */
                 if ($include_mlist_div) {
                     $wpgmza_tmp_head .= "<div id=\"wpgmza_marker_holder_" . $map_id . "\" class='wpgmza_marker_holder' style=\"width:{$width};\">";
                 }
                 $wpgmza_tmp_head .= "<table id=\"wpgmza_table_" . $map_id . "\" class=\"wpgmza_table responsive\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:{$width};\">";
                 $wpgmza_tmp_head .= "<thead>";
                 $wpgmza_tmp_head .= "<tr>";
                 if (isset($hide_icon_column) && $hide_icon_column == "yes") {
                 } else {
                     $wpgmza_tmp_head .= "<th class='wpgmza_table_marker'><strong></strong></th>";
                 }
                 if (isset($hide_title_column) && $hide_title_column == "yes") {
                 } else {
                     $wpgmza_tmp_head .= "<th class='wpgmza_table_title'><strong>" . __("Title", "wp-google-maps") . "</strong></th>";
                 }
                 if (isset($hide_category_column) && $hide_category_column == "yes") {
                 } else {
                     $wpgmza_tmp_head .= "<th class='wpgmza_table_category'><strong>" . __("Category", "wp-google-maps") . "</strong></th>";
                 }
                 if (isset($hide_address_column) && $hide_address_column == "yes") {
                 } else {
                     $wpgmza_tmp_head .= "<th class='wpgmza_table_address'><strong>" . __("Address", "wp-google-maps") . "</strong></th>";
                 }
                 if (isset($hide_description_column) && $hide_description_column == "yes") {
                 } else {
                     $wpgmza_tmp_head .= "<th class='wpgmza_table_description'><strong>" . __("Description", "wp-google-maps") . "</strong></th>";
                 }
                 /* deprecated in 5.54
                    $wpgmza_tmp_head .= "   <th width='1' style='display:none; width:1px !important;'>".__("Marker ID","wp-google-maps")."</th>";
                    */
                 $wpgmza_tmp_head .= "</tr>";
                 $wpgmza_tmp_head .= "</thead>";
                 $wpgmza_tmp_head .= "<tbody>";
             } else {
                 if ($type == 3) {
                     $wpgmza_tmp_head .= "<div id=\"wpgmza_marker_list_container_" . $map_id . "\" class=\"wpgmza_marker_carousel\"><div id=\"wpgmza_marker_list_" . $map_id . "\" class=\"wpgmza_marker_carousel owl-carousel\" style=\"width:{$width};\">";
                 } else {
                     if ($type == 4) {
                         $wpgmza_tmp_head .= " <div id=\"wpgmza_marker_list_" . $map_id . "\" class=\"wpgmza_marker_list_class wpgmza_basic_list\" style='width:" . $width . "'>";
                     } else {
                         /* advanced marker listing by default */
                         $wpgmza_tmp_head .= "<div id=\"wpgmza_marker_holder_" . $map_id . "\" style=\"width:{$width};\">";
                         $wpgmza_tmp_head .= "<table id=\"wpgmza_table_" . $map_id . "\" class=\"wpgmza_table responsive\" cellspacing=\"0\" cellpadding=\"0\" style=\"width:{$width};\">";
                         $wpgmza_tmp_head .= "<thead>";
                         $wpgmza_tmp_head .= "<tr>";
                         if (isset($hide_icon_column) && $hide_icon_column == "yes") {
                         } else {
                             $wpgmza_tmp_head .= "<th class='wpgmza_table_marker'><strong></strong></th>";
                         }
                         if (isset($hide_title_column) && $hide_title_column == "yes") {
                         } else {
                             $wpgmza_tmp_head .= "<th class='wpgmza_table_title'><strong>" . __("Title", "wp-google-maps") . "</strong></th>";
                         }
                         if (isset($hide_category_column) && $hide_category_column == "yes") {
                         } else {
                             $wpgmza_tmp_head .= "<th class='wpgmza_table_category'><strong>" . __("Category", "wp-google-maps") . "</strong></th>";
                         }
                         if (isset($hide_address_column) && $hide_address_column == "yes") {
                         } else {
                             $wpgmza_tmp_head .= "<th class='wpgmza_table_address'><strong>" . __("Address", "wp-google-maps") . "</strong></th>";
                         }
                         if (isset($hide_description_column) && $hide_description_column == "yes") {
                         } else {
                             $wpgmza_tmp_head .= "<th class='wpgmza_table_description'><strong>" . __("Description", "wp-google-maps") . "</strong></th>";
                         }
                         $wpgmza_tmp_head .= "   <th width='1' style='display:none; width:1px !important;'></th>";
                         $wpgmza_tmp_head .= "</tr>";
                         $wpgmza_tmp_head .= "</thead>";
                         $wpgmza_tmp_head .= "<tbody>";
                     }
                 }
             }
         }
     }
     if ($admin) {
         $wpgmza_tmp_footer .= "</tbody></table>";
     } else {
         if ($type == 1) {
             $wpgmza_tmp_footer .= "</div>";
         } else {
             if ($type == 2) {
                 $wpgmza_tmp_footer .= "</tbody></table>";
                 if ($include_mlist_div) {
                     $wpgmza_tmp_footer .= "</div><!-- end of marker list -->";
                 }
             } else {
                 if ($type == 3) {
                     $wpgmza_tmp_footer .= "</div></div>";
                 } else {
                     if ($type == 4) {
                         $wpgmza_tmp_footer .= "</div>";
                     } else {
                         $wpgmza_tmp_footer .= "</tbody></table></div>";
                     }
                 }
             }
         }
     }
     return $wpgmza_tmp_head . $wpgmza_tmp_body . $wpgmza_tmp_footer;
 }
function wpgmaps_b_admin_edit_poly_javascript($mapid, $polyid)
{
    $res = wpgmza_get_map_data($mapid);
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    $wpgmza_lat = $res->map_start_lat;
    $wpgmza_lng = $res->map_start_lng;
    $wpgmza_map_type = $res->type;
    $wpgmza_width = $res->map_width;
    $wpgmza_height = $res->map_height;
    $wpgmza_width_type = $res->map_width_type;
    $wpgmza_height_type = $res->map_height_type;
    if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") {
        $wpgmza_map_type = "ROADMAP";
    } else {
        if ($wpgmza_map_type == "2") {
            $wpgmza_map_type = "SATELLITE";
        } else {
            if ($wpgmza_map_type == "3") {
                $wpgmza_map_type = "HYBRID";
            } else {
                if ($wpgmza_map_type == "4") {
                    $wpgmza_map_type = "TERRAIN";
                } else {
                    $wpgmza_map_type = "ROADMAP";
                }
            }
        }
    }
    $start_zoom = $res->map_start_zoom;
    if ($start_zoom < 1 || !$start_zoom) {
        $start_zoom = 5;
    }
    $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
    ?>
        <script type="text/javascript">
                       var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
                       document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?sensor=false' type='text/javascript'%3E%3C/script%3E"));
        </script>
        <link rel='stylesheet' id='wpgooglemaps-css'  href='<?php 
    echo wpgmaps_get_plugin_url();
    ?>
/css/wpgmza_style.css' type='text/css' media='all' />
        <script type="text/javascript" >
             // polygons variables
            var poly;
            var poly_markers = [];
            var poly_path = new google.maps.MVCArray;
                
            jQuery(document).ready(function(){
                
                    function wpgmza_InitMap() {
                        var myLatLng = new google.maps.LatLng(<?php 
    echo $wpgmza_lat;
    ?>
,<?php 
    echo $wpgmza_lng;
    ?>
);
                        MYMAP.init('#wpgmza_map', myLatLng, <?php 
    echo $start_zoom;
    ?>
);
                    }
                    jQuery("#wpgmza_map").css({
                        height:'<?php 
    echo $wpgmza_height;
    echo $wpgmza_height_type;
    ?>
',
                        width:'<?php 
    echo $wpgmza_width;
    echo $wpgmza_width_type;
    ?>
'
                    });
                    wpgmza_InitMap();
                    
                    
                    jQuery("#poly_line").focusout(function() {
                        poly.setOptions({ strokeColor: "#"+jQuery("#poly_line").val() }); 
                    });
                    jQuery("#poly_fill").focusout(function() {
                        poly.setOptions({ fillColor: "#"+jQuery("#poly_fill").val() }); 
                    });
                    jQuery("#poly_opacity").keyup(function() {
                        poly.setOptions({ fillOpacity: jQuery("#poly_opacity").val() }); 
                    });
                    jQuery("#poly_line_opacity").keyup(function() {
                        poly.setOptions({ strokeOpacity: jQuery("#poly_line_opacity").val() }); 
                    });
            });
            

            var MYMAP = {
                map: null,
                bounds: null
            }
            MYMAP.init = function(selector, latLng, zoom) {
                  var myOptions = {
                    zoom:zoom,
                    center: latLng,
                    zoomControl: true,
                    panControl: true,
                    mapTypeControl: true,
                    streetViewControl: false,
                    mapTypeId: google.maps.MapTypeId.<?php 
    echo $wpgmza_map_type;
    ?>
                  }
                this.map = new google.maps.Map(jQuery(selector)[0], myOptions);
                this.bounds = new google.maps.LatLngBounds();
                // polygons
                
                
                addPolygon();
                

            }
            function addPolygon() {
                <?php 
    $poly_array = wpgmza_b_return_polygon_array($polyid);
    $polyoptions = wpgmza_b_return_poly_options($polyid);
    $linecolor = $polyoptions->linecolor;
    $lineopacity = $polyoptions->lineopacity;
    $fillcolor = $polyoptions->fillcolor;
    $fillopacity = $polyoptions->opacity;
    if (!$linecolor) {
        $linecolor = "000000";
    }
    if (!$fillcolor) {
        $fillcolor = "66FF00";
    }
    if ($fillopacity == "") {
        $fillopacity = "0.5";
    }
    if ($lineopacity == "") {
        $lineopacity = "1";
    }
    $linecolor = "#" . $linecolor;
    $fillcolor = "#" . $fillcolor;
    foreach ($poly_array as $single_poly) {
        $poly_data_raw = str_replace(" ", "", $single_poly);
        $poly_data_raw = explode(",", $poly_data_raw);
        $lat = $poly_data_raw[0];
        $lng = $poly_data_raw[1];
        ?>
                    var temp_gps = new google.maps.LatLng(<?php 
        echo $lat;
        ?>
, <?php 
        echo $lng;
        ?>
);
                    addExistingPoint(temp_gps);
                    updatePolyPath(poly_path);
                    
                    
                    
                    <?php 
    }
    ?>
                
                poly = new google.maps.Polygon({
                    strokeWeight: 3,
                    strokeColor: "<?php 
    echo $linecolor;
    ?>
",
                    strokeOpacity: "<?php 
    echo $lineopacity;
    ?>
",
                    fillOpacity: "<?php 
    echo $fillopacity;
    ?>
",
                    fillColor: "<?php 
    echo $fillcolor;
    ?>
"
                });
                poly.setMap(MYMAP.map);
                poly.setPaths(poly_path);
                google.maps.event.addListener(MYMAP.map, 'click', addPoint);
            }
            function addExistingPoint(temp_gps) {
                poly_path.insertAt(poly_path.length, temp_gps);
                var poly_marker = new google.maps.Marker({
                  position: temp_gps,
                  map: MYMAP.map,
                  draggable: true
                });
                poly_markers.push(poly_marker);
                poly_marker.setTitle("#" + poly_path.length);
                google.maps.event.addListener(poly_marker, 'click', function() {
                      poly_marker.setMap(null);
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      poly_markers.splice(i, 1);
                      poly_path.removeAt(i);
                      updatePolyPath(poly_path);    
                      }
                    );

                    google.maps.event.addListener(poly_marker, 'dragend', function() {
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      poly_path.setAt(i, poly_marker.getPosition());
                      updatePolyPath(poly_path);    
                      }
                    );
            }
            function addPoint(event) {
                
                    poly_path.insertAt(poly_path.length, event.latLng);

                    var poly_marker = new google.maps.Marker({
                      position: event.latLng,
                      map: MYMAP.map,
                      icon: "<?php 
    echo wpgmaps_get_plugin_url() . "/images/marker.png";
    ?>
",
                      draggable: true
                    });
                    

                    
                    poly_markers.push(poly_marker);
                    poly_marker.setTitle("#" + poly_path.length);

                    google.maps.event.addListener(poly_marker, 'click', function() {
                      poly_marker.setMap(null);
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      poly_markers.splice(i, 1);
                      poly_path.removeAt(i);
                      updatePolyPath(poly_path);    
                      }
                    );

                    google.maps.event.addListener(poly_marker, 'dragend', function() {
                      for (var i = 0, I = poly_markers.length; i < I && poly_markers[i] != poly_marker; ++i);
                      poly_path.setAt(i, poly_marker.getPosition());
                      updatePolyPath(poly_path);    
                      }
                    );
                        
                        
                    updatePolyPath(poly_path);    
              }
              
              function updatePolyPath(poly_path) {
                var temp_array;
                temp_array = "";
                poly_path.forEach(function(latLng, index) { 
//                  temp_array = temp_array + " ["+ index +"] => "+ latLng + ", ";
                  temp_array = temp_array + latLng + ",";
                }); 
                jQuery("#poly_line_list").html(temp_array);
              }            
             

        </script>
        <?php 
}
function wpgmaps_admin_javascript_gold()
{
    global $wpdb;
    global $wpgmza_tblname_maps;
    $ajax_nonce = wp_create_nonce("wpgmza");
    if (isset($_GET['page']) && isset($_GET['action']) && is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "edit_marker") {
        wpgmaps_admin_edit_marker_javascript();
    } else {
        if (isset($_GET['page']) && isset($_GET['action']) && is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "add_poly") {
            wpgmaps_b_admin_add_poly_javascript($_GET['map_id']);
        } else {
            if (isset($_GET['page']) && isset($_GET['action']) && is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "edit_poly") {
                wpgmaps_b_admin_edit_poly_javascript($_GET['map_id'], $_GET['poly_id']);
            } else {
                if (isset($_GET['page']) && isset($_GET['action']) && is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "add_polyline") {
                    wpgmaps_b_admin_add_polyline_javascript($_GET['map_id']);
                } else {
                    if (isset($_GET['page']) && isset($_GET['action']) && is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "edit_polyline") {
                        wpgmaps_b_admin_edit_polyline_javascript($_GET['map_id'], $_GET['poly_id']);
                    } else {
                        if (isset($_GET['page']) && isset($_GET['action']) && is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "edit") {
                            wpgmaps_update_xml_file($_GET['map_id']);
                            $res = wpgmza_get_map_data($_GET['map_id']);
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            $wpgmza_lat = $res->map_start_lat;
                            $wpgmza_lng = $res->map_start_lng;
                            $wpgmza_width = $res->map_width;
                            $wpgmza_height = $res->map_height;
                            $wpgmza_width_type = $res->map_width_type;
                            $wpgmza_height_type = $res->map_height_type;
                            $wpgmza_map_type = $res->type;
                            $wpgmza_default_icon = $res->default_marker;
                            $kml = $res->kml;
                            $fusion = $res->fusion;
                            $wpgmza_traffic = $res->traffic;
                            $wpgmza_bicycle = $res->bicycle;
                            $wpgmza_dbox = $res->dbox;
                            $wpgmza_dbox_width = $res->dbox_width;
                            $map_other_settings = maybe_unserialize($res->other_settings);
                            if (isset($map_other_settings['weather_layer'])) {
                                $weather_layer = $map_other_settings['weather_layer'];
                            } else {
                                $weather_layer = "";
                            }
                            if (isset($map_other_settings['weather_layer_temp_type'])) {
                                $weather_layer_temp_type = $map_other_settings['weather_layer_temp_type'];
                            } else {
                                $weather_layer_temp_type = 0;
                            }
                            if (isset($map_other_settings['cloud_layer'])) {
                                $cloud_layer = $map_other_settings['cloud_layer'];
                            } else {
                                $cloud_layer = "";
                            }
                            if (isset($map_other_settings['transport_layer'])) {
                                $transport_layer = $map_other_settings['transport_layer'];
                            } else {
                                $transport_layer = "";
                            }
                            if (isset($map_other_settings['map_max_zoom'])) {
                                $wpgmza_max_zoom = intval($map_other_settings['map_max_zoom']);
                            } else {
                                $wpgmza_max_zoom = 0;
                            }
                            if (isset($map_other_settings['wpgmza_theme_data'])) {
                                $wpgmza_theme_data = $map_other_settings['wpgmza_theme_data'];
                            } else {
                                $wpgmza_theme_data = false;
                            }
                            if ($wpgmza_default_icon == "0") {
                                $wpgmza_default_icon = "";
                            }
                            if (!$wpgmza_map_type || $wpgmza_map_type == "" || $wpgmza_map_type == "1") {
                                $wpgmza_map_type = "ROADMAP";
                            } else {
                                if ($wpgmza_map_type == "2") {
                                    $wpgmza_map_type = "SATELLITE";
                                } else {
                                    if ($wpgmza_map_type == "3") {
                                        $wpgmza_map_type = "HYBRID";
                                    } else {
                                        if ($wpgmza_map_type == "4") {
                                            $wpgmza_map_type = "TERRAIN";
                                        } else {
                                            $wpgmza_map_type = "ROADMAP";
                                        }
                                    }
                                }
                            }
                            $start_zoom = $res->map_start_zoom;
                            if ($start_zoom < 1 || !$start_zoom) {
                                $start_zoom = 5;
                            }
                            if (!$wpgmza_lat || !$wpgmza_lng) {
                                $wpgmza_lat = "51.5081290";
                                $wpgmza_lng = "-0.1280050";
                            }
                            $wpgmza_styling_enabled = $res->styling_enabled;
                            $wpgmza_styling_json = $res->styling_json;
                            // marker sorting functionality
                            if ($res->order_markers_by == 1) {
                                $order_by = 0;
                            } else {
                                if ($res->order_markers_by == 2) {
                                    $order_by = 2;
                                } else {
                                    if ($res->order_markers_by == 3) {
                                        $order_by = 3;
                                    } else {
                                        if ($res->order_markers_by == 4) {
                                            $order_by = 4;
                                        } else {
                                            $order_by = 0;
                                        }
                                    }
                                }
                            }
                            if ($res->order_markers_choice == 1) {
                                $order_choice = "asc";
                            } else {
                                $order_choice = "desc";
                            }
                            if (isset($wpgmza_settings['wpgmza_api_version'])) {
                                $api_version = $wpgmza_settings['wpgmza_api_version'];
                            } else {
                                $api_version = "";
                            }
                            if (isset($api_version) && $api_version != "") {
                                $api_version_string = "v={$api_version}&";
                            } else {
                                $api_version_string = "v=3.14&";
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_marker_pull'])) {
                                $marker_pull = $wpgmza_settings['wpgmza_settings_marker_pull'];
                            } else {
                                $marker_pull = "1";
                            }
                            if (isset($marker_pull) && $marker_pull == "0") {
                                if (!defined('PHP_VERSION_ID')) {
                                    $phpversion = explode('.', PHP_VERSION);
                                    define('PHP_VERSION_ID', $phpversion[0] * 10000 + $phpversion[1] * 100 + $phpversion[2]);
                                }
                                if (PHP_VERSION_ID < 50300) {
                                    $markers = json_encode(wpgmaps_return_markers_pro($_GET['map_id']));
                                } else {
                                    $markers = json_encode(wpgmaps_return_markers_pro($_GET['map_id']), JSON_HEX_APOS);
                                }
                            }
                            ?>




     <?php 
                            if ($cloud_layer == 1 || $weather_layer == 1) {
                                ?>

    <script type="text/javascript">
        var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
        document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?<?php 
                                echo $api_version_string;
                                ?>
sensor=false&libraries=weather' type='text/javascript'%3E%3C/script%3E"));
    </script>

    <?php 
                            } else {
                                ?>

    <script type="text/javascript">
        var gmapsJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
        document.write(unescape("%3Cscript src='" + gmapsJsHost + "maps.google.com/maps/api/js?<?php 
                                echo $api_version_string;
                                ?>
sensor=false' type='text/javascript'%3E%3C/script%3E"));
    </script>

    <?php 
                            }
                            ?>
    <link rel="stylesheet" type="text/css" media="all" href="<?php 
                            echo wpgmaps_get_plugin_url();
                            ?>
/css/data_table.css" />
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />

    <script type="text/javascript" src="<?php 
                            echo wpgmaps_get_plugin_url();
                            ?>
/js/markerclusterer.js"></script>
    <script type="text/javascript" src="<?php 
                            echo wpgmaps_get_plugin_url();
                            ?>
/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" >

    var marker_pull = '<?php 
                            echo $marker_pull;
                            ?>
';
    <?php 
                            if (isset($markers) && strlen($markers) > 0 && $markers != "[]") {
                                ?>
var db_marker_array = JSON.stringify(<?php 
                                echo $markers;
                                ?>
);<?php 
                            } else {
                                echo "var db_marker_array = '';";
                            }
                            ?>
    jQuery(function() {


            jQuery(document).ready(function(){

                    
                    jQuery("#wpgmaps_show_advanced").click(function() {
                      jQuery("#wpgmaps_advanced_options").show();
                      jQuery("#wpgmaps_show_advanced").hide();
                      jQuery("#wpgmaps_hide_advanced").show();

                    });
                    jQuery("#wpgmaps_hide_advanced").click(function() {
                      jQuery("#wpgmaps_advanced_options").hide();
                      jQuery("#wpgmaps_show_advanced").show();
                      jQuery("#wpgmaps_hide_advanced").hide();

                    });
                    wpgmzaTable = jQuery('#wpgmza_table').dataTable({
                        "bProcessing": true,
                        "aaSorting": [[ <?php 
                            echo "{$order_by}";
                            ?>
, "<?php 
                            echo $order_choice;
                            ?>
" ]]
                    });
                    function wpgmza_reinitialisetbl() {
                        wpgmzaTable.fnClearTable( 0 );
                        wpgmzaTable = jQuery('#wpgmza_table').dataTable({
                            "bProcessing": true,
                            "aaSorting": [[ <?php 
                            echo "{$order_by}";
                            ?>
, "<?php 
                            echo $order_choice;
                            ?>
" ]]
                        });
                    }
                    function wpgmza_InitMap() {
                        var myLatLng = new google.maps.LatLng(<?php 
                            echo $wpgmza_lat;
                            ?>
,<?php 
                            echo $wpgmza_lng;
                            ?>
);
                        MYMAP.init('#wpgmza_map', myLatLng, <?php 
                            echo $start_zoom;
                            ?>
);
                        UniqueCode=Math.round(Math.random()*10000);
                        MYMAP.placeMarkers('<?php 
                            echo wpgmaps_get_marker_url($_GET['map_id']);
                            ?>
?u='+UniqueCode,<?php 
                            echo $_GET['map_id'];
                            ?>
);
                    }

                    jQuery("#wpgmza_map").css({
                        height:'<?php 
                            echo $wpgmza_height;
                            echo $wpgmza_height_type;
                            ?>
',
                        width:'<?php 
                            echo $wpgmza_width;
                            echo $wpgmza_width_type;
                            ?>
'

                    });
                    var geocoder = new google.maps.Geocoder();
                    wpgmza_InitMap();




                    jQuery("body").on("click", ".wpgmza_del_btn", function() {
                        var cur_id = jQuery(this).attr("id");
                        var wpgm_map_id = "0";
                        if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); }
                        var data = {
                                action: 'delete_marker',
                                security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                map_id: wpgm_map_id,
                                marker_id: cur_id
                        };
                        jQuery.post(ajaxurl, data, function(response) {
                                returned_data = JSON.parse(response);
                                db_marker_array = JSON.stringify(returned_data.marker_data);
                                wpgmza_InitMap();
                                jQuery("#wpgmza_marker_holder").html(JSON.parse(response).table_html);
                                wpgmza_reinitialisetbl();
                        });

                    });
                    jQuery("body").on("click", ".wpgmza_polyline_del_btn", function() {
                        var cur_id = jQuery(this).attr("id");
                        var wpgm_map_id = "0";
                        if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); }
                        var data = {
                                action: 'delete_polyline',
                                security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                map_id: wpgm_map_id,
                                poly_id: cur_id
                        };
                        jQuery.post(ajaxurl, data, function(response) {
                                wpgmza_InitMap();
                                jQuery("#wpgmza_polyline_holder").html(response);
                                window.location.reload();

                        });

                    });

                    jQuery("body").on("click", ".wpgmza_edit_btn", function() {
                        var cur_id = jQuery(this).attr("id");

                        var wpgmza_edit_title = jQuery("#wpgmza_hid_marker_title_"+cur_id).val();
                        wpgmza_edit_address = jQuery("#wpgmza_hid_marker_address_"+cur_id).val();
                        wpgmza_edit_lat = jQuery("#wpgmza_hid_marker_lat_"+cur_id).val();
                        wpgmza_edit_lng = jQuery("#wpgmza_hid_marker_lng_"+cur_id).val();
                        
                        
                        var wpgmza_edit_desc = jQuery("#wpgmza_hid_marker_desc_"+cur_id).val();
                        var wpgmza_edit_pic = jQuery("#wpgmza_hid_marker_pic_"+cur_id).val();
                        var wpgmza_edit_link = jQuery("#wpgmza_hid_marker_link_"+cur_id).val();
                        var wpgmza_edit_icon = jQuery("#wpgmza_hid_marker_icon_"+cur_id).val();
                        var wpgmza_edit_anim = jQuery("#wpgmza_hid_marker_anim_"+cur_id).val();
                        var wpgmza_edit_category = jQuery("#wpgmza_hid_marker_category_"+cur_id).val();
                        var wpgmza_edit_retina = jQuery("#wpgmza_hid_marker_retina_"+cur_id).val();
                        var wpgmza_edit_infoopen = jQuery("#wpgmza_hid_marker_infoopen_"+cur_id).val();
                        jQuery("#wpgmza_edit_id").val(cur_id);
                        jQuery("#wpgmza_add_title").val(wpgmza_edit_title);
                        jQuery("#wpgmza_add_address").val(wpgmza_edit_address);
                        jQuery("#wpgmza_add_desc").val(wpgmza_edit_desc);
                        jQuery("#wpgmza_add_pic").val(wpgmza_edit_pic);
                        jQuery("#wpgmza_link_url").val(wpgmza_edit_link);
                        jQuery("#wpgmza_animation").val(wpgmza_edit_anim);
                        
                        jQuery('input[name=wpgmza_add_retina]').removeAttr('checked');
                        if (wpgmza_edit_retina === 0 || wpgmza_edit_retina === "0") { } else {
                            jQuery("#wpgmza_add_retina").prop('checked', true);
                        }

                        var cat_array = wpgmza_edit_category.split(",");
                        jQuery('input[name=wpgmza_cat_checkbox]').removeAttr('checked');
                        cat_array.forEach(function(entry) {
                            if (entry === 0) { } else {
                                jQuery("#wpgmza_cat_checkbox_"+entry).prop('checked', true);
                            }
                        });
                        
                        jQuery("#wpgmza_infoopen").val(wpgmza_edit_infoopen);
                        jQuery("#wpgmza_add_custom_marker").val(wpgmza_edit_icon);
                        if (wpgmza_edit_icon != "")
                          jQuery("#wpgmza_cmm").html("<img src='"+wpgmza_edit_icon+"' />");
                        else
                          jQuery("#wpgmza_cmm").html("&nbsp;"); 
                        jQuery("#wpgmza_addmarker_div").hide();
                        jQuery("#wpgmza_editmarker_div").show();


                    });
                    jQuery("body").on("click", ".wpgmza_approve_btn", function() {
                        var cur_id = jQuery(this).attr("id");
                        var wpgm_map_id = "0";
                        if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); }
                        var data = {
                                action: 'approve_marker',
                                security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                map_id: wpgm_map_id,
                                marker_id: cur_id
                        };
                        jQuery.post(ajaxurl, data, function(response) {
                                returned_data = JSON.parse(response);
                                db_marker_array = JSON.stringify(returned_data.marker_data);
                                wpgmza_InitMap();
                                jQuery("#wpgmza_marker_holder").html(JSON.parse(response).table_html);
                                wpgmza_reinitialisetbl();

                        });

                    });
                    jQuery("body").on("click", ".wpgmza_poly_del_btn", function() {
                        var cur_id = jQuery(this).attr("id");
                        var wpgm_map_id = "0";
                        if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); }
                        var data = {
                                action: 'delete_poly',
                                security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                map_id: wpgm_map_id,
                                poly_id: cur_id
                        };
                        jQuery.post(ajaxurl, data, function(response) {
                                wpgmza_InitMap();
                                jQuery("#wpgmza_poly_holder").html(response);
                                window.location.reload();

                        });

                    });


                    jQuery("#wpgmza_addmarker").click(function(){
                        jQuery("#wpgmza_addmarker").hide();
                        jQuery("#wpgmza_addmarker_loading").show();

                        var wpgm_title = "";
                        var wpgm_address = "0";
                        var wpgm_desc = "0";
                        var wpgm_pic = "0";
                        var wpgm_link = "0";
                        var wpgm_icon = "0";
                        var wpgm_gps = "0";

                        var wpgm_anim = "0";
                        var wpgm_category = "0";
                        var wpgm_retina = "0";
                        var wpgm_infoopen = "0";
                        var wpgm_map_id = "0";
                        if (document.getElementsByName("wpgmza_add_title").length > 0) { wpgm_title = jQuery("#wpgmza_add_title").val(); }
                        if (document.getElementsByName("wpgmza_add_address").length > 0) { wpgm_address = jQuery("#wpgmza_add_address").val(); }
                        if (document.getElementsByName("wpgmza_add_desc").length > 0) { wpgm_desc = jQuery("#wpgmza_add_desc").val(); }
                        if (document.getElementsByName("wpgmza_add_pic").length > 0) { wpgm_pic = jQuery("#wpgmza_add_pic").val(); }
                        if (document.getElementsByName("wpgmza_link_url").length > 0) { wpgm_link = jQuery("#wpgmza_link_url").val(); }
                        if (document.getElementsByName("wpgmza_add_custom_marker").length > 0) { wpgm_icon = jQuery("#wpgmza_add_custom_marker").val(); }
                        if (document.getElementsByName("wpgmza_animation").length > 0) { wpgm_anim = jQuery("#wpgmza_animation").val(); }
                        
                        var Checked = jQuery('input[name="wpgmza_add_retina"]:checked').length > 0;
                        if (Checked) { wpgm_retina = "1"; } else { wpgm_retina = "0"; }

                        if (document.getElementsByName("wpgmza_category").length > 0) { wpgm_category = jQuery("#wpgmza_category").val(); }
                        
                    
                        var checkValues = jQuery('input[name=wpgmza_cat_checkbox]:checked').map(function() {
                            return jQuery(this).val();
                        }).get();
                        if (checkValues.length > 0) { wpgm_category = checkValues; }
                        wpgm_category.toString();
                        
                        
                        if (document.getElementsByName("wpgmza_infoopen").length > 0) { wpgm_infoopen = jQuery("#wpgmza_infoopen").val(); }
                        if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); }
                        /* first check if user has added a GPS co-ordinate */
                        checker = wpgm_address.split(",");
                        var wpgm_lat = "";
                        var wpgm_lng = "";
                        wpgm_lat = checker[0];
                        wpgm_lng = checker[1];
                        checker1 = parseFloat(checker[0]);
                        checker2 = parseFloat(checker[1]);
                        if ((wpgm_lat.match(/[a-zA-Z]/g) === null && wpgm_lng.match(/[a-zA-Z]/g) === null) && checker.length === 2 && (checker1 != NaN && (checker1 <= 90 || checker1 >= -90)) && (checker2 != NaN && (checker2 <= 90 || checker2 >= -90))) {
                            var data = {
                                action: 'add_marker',
                                security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                map_id: wpgm_map_id,
                                title: wpgm_title,
                                address: wpgm_address,
                                desc: wpgm_desc,
                                link: wpgm_link,
                                icon: wpgm_icon,
                                retina: wpgm_retina,
                                pic: wpgm_pic,
                                anim: wpgm_anim,
                                category: wpgm_category,
                                infoopen: wpgm_infoopen,
                                lat: wpgm_lat,
                                lng: wpgm_lng
                            };


                            jQuery.post(ajaxurl, data, function(response) {
                                    returned_data = JSON.parse(response);
                                    db_marker_array = JSON.stringify(returned_data.marker_data);
                                    wpgmza_InitMap();
                                    jQuery("#wpgmza_marker_holder").html(JSON.parse(response).table_html);
                                    jQuery("#wpgmza_addmarker").show();
                                    jQuery("#wpgmza_addmarker_loading").hide();

                                    jQuery("#wpgmza_add_title").val("");
                                    jQuery("#wpgmza_add_address").val("");
                                    jQuery("#wpgmza_add_desc").val("");
                                    jQuery("#wpgmza_add_pic").val("");
                                    jQuery("#wpgmza_link_url").val("");
                                    jQuery("#wpgmza_animation").val("0");
                                    jQuery("#wpgmza_add_retina").attr('checked',false);
                                    jQuery("#wpgmza_edit_id").val("");
                                    jQuery('input[name=wpgmza_cat_checkbox]').attr('checked',false);
                                    wpgmza_reinitialisetbl();
                            });
                            
                            
                        } else { 
                            geocoder.geocode( { 'address': wpgm_address}, function(results, status) {
                                if (status == google.maps.GeocoderStatus.OK) {
                                    wpgm_gps = String(results[0].geometry.location);
                                    var latlng1 = wpgm_gps.replace("(","");
                                    var latlng2 = latlng1.replace(")","");
                                    var latlngStr = latlng2.split(",",2);
                                    var wpgm_lat = parseFloat(latlngStr[0]);
                                    var wpgm_lng = parseFloat(latlngStr[1]);

                                    var data = {
                                        action: 'add_marker',
                                        security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                        map_id: wpgm_map_id,
                                        title: wpgm_title,
                                        address: wpgm_address,
                                        desc: wpgm_desc,
                                        link: wpgm_link,
                                        icon: wpgm_icon,
                                        retina: wpgm_retina,
                                        pic: wpgm_pic,
                                        anim: wpgm_anim,
                                        category: wpgm_category,
                                        infoopen: wpgm_infoopen,
                                        lat: wpgm_lat,
                                        lng: wpgm_lng
                                    };


                                    jQuery.post(ajaxurl, data, function(response) {
                                            returned_data = JSON.parse(response);
                                            db_marker_array = JSON.stringify(returned_data.marker_data);
                                            wpgmza_InitMap();
                                            jQuery("#wpgmza_marker_holder").html(JSON.parse(response).table_html);
                                            jQuery("#wpgmza_addmarker").show();
                                            jQuery("#wpgmza_addmarker_loading").hide();

                                            jQuery("#wpgmza_add_title").val("");
                                            jQuery("#wpgmza_add_address").val("");
                                            jQuery("#wpgmza_add_desc").val("");
                                            jQuery("#wpgmza_add_pic").val("");
                                            jQuery("#wpgmza_link_url").val("");
                                            jQuery("#wpgmza_animation").val("0");
                                            jQuery("#wpgmza_add_retina").attr('checked',false);
                                            jQuery("#wpgmza_edit_id").val("");
                                            jQuery('input[name=wpgmza_cat_checkbox]').attr('checked',false);
                                            wpgmza_reinitialisetbl();
                                    });

                                } else {
                                    alert("<?php 
                            _e("Geocode was not successful for the following reason", "wp-google-maps");
                            ?>
: " + status);
                                }
                            });
                        }


                    });
                    jQuery("#wpgmza_editmarker").click(function(){

                        jQuery("#wpgmza_editmarker_div").hide();
                        jQuery("#wpgmza_editmarker_loading").show();


                        var wpgm_edit_id;
                        wpgm_edit_id = parseInt(jQuery("#wpgmza_edit_id").val());
                        var wpgm_title = "";
                        var wpgm_address = "0";
                        var wpgm_desc = "0";
                        var wpgm_pic = "0";
                        var wpgm_link = "0";
                        var wpgm_anim = "0";
                        var wpgm_category = "0";
                        var wpgm_infoopen = "0";
                        var wpgm_icon = "";
                        var wpgm_retina = "0";
                        var wpgm_map_id = "0";
                        var wpgm_gps = "0";
                        if (document.getElementsByName("wpgmza_add_title").length > 0) { wpgm_title = jQuery("#wpgmza_add_title").val(); }
                        if (document.getElementsByName("wpgmza_add_address").length > 0) { wpgm_address = jQuery("#wpgmza_add_address").val(); }
                        if (document.getElementsByName("wpgmza_add_desc").length > 0) { wpgm_desc = jQuery("#wpgmza_add_desc").val(); }
                        if (document.getElementsByName("wpgmza_add_pic").length > 0) { wpgm_pic = jQuery("#wpgmza_add_pic").val(); }
                        if (document.getElementsByName("wpgmza_link_url").length > 0) { wpgm_link = jQuery("#wpgmza_link_url").val(); }
                        if (document.getElementsByName("wpgmza_animation").length > 0) { wpgm_anim = jQuery("#wpgmza_animation").val(); }
                        if (document.getElementsByName("wpgmza_category").length > 0) { wpgm_category = jQuery("#wpgmza_category").val(); }
                        var Checked = jQuery('input[name="wpgmza_add_retina"]:checked').length > 0;
                        if (Checked) { wpgm_retina = "1"; } else { wpgm_retina = "0"; }
                        
                        
                        var checkValues = jQuery('input[name=wpgmza_cat_checkbox]:checked').map(function() {
                            return jQuery(this).val();
                        }).get();
                        if (checkValues.length > 0) { wpgm_category = checkValues; }
                        wpgm_category.toString();
                        if (document.getElementsByName("wpgmza_infoopen").length > 0) { wpgm_infoopen = jQuery("#wpgmza_infoopen").val(); }
                        if (document.getElementsByName("wpgmza_add_custom_marker").length > 0) { wpgm_icon = jQuery("#wpgmza_add_custom_marker").val(); }
                        if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); }


                        var do_geocode;
                        if (wpgm_address === wpgmza_edit_address) {
                            do_geocode = false;
                            var wpgm_lat = wpgmza_edit_lat;
                            var wpgm_lng = wpgmza_edit_lng;
                        } else { 
                            do_geocode = true;
                        }

                        if (do_geocode === true) {


                        geocoder.geocode( { 'address': wpgm_address}, function(results, status) {
                            if (status == google.maps.GeocoderStatus.OK) {
                                wpgm_gps = String(results[0].geometry.location);
                                var latlng1 = wpgm_gps.replace("(","");
                                var latlng2 = latlng1.replace(")","");
                                var latlngStr = latlng2.split(",",2);
                                var wpgm_lat = parseFloat(latlngStr[0]);
                                var wpgm_lng = parseFloat(latlngStr[1]);

                                var data = {
                                        action: 'edit_marker',
                                        security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                        map_id: wpgm_map_id,
                                        edit_id: wpgm_edit_id,
                                        title: wpgm_title,
                                        address: wpgm_address,
                                        lat: wpgm_lat,
                                        lng: wpgm_lng,
                                        icon: wpgm_icon,
                                        retina: wpgm_retina,
                                        desc: wpgm_desc,
                                        link: wpgm_link,
                                        pic: wpgm_pic,
                                        anim: wpgm_anim,
                                        category: wpgm_category,
                                        infoopen: wpgm_infoopen
                                };

                                jQuery.post(ajaxurl, data, function(response) {
                                    returned_data = JSON.parse(response);
                                    db_marker_array = JSON.stringify(returned_data.marker_data);
                                    wpgmza_InitMap();
                                    jQuery("#wpgmza_marker_holder").html(JSON.parse(response).table_html);
                                    jQuery("#wpgmza_addmarker_div").show();
                                    jQuery("#wpgmza_editmarker_loading").hide();
                                    jQuery("#wpgmza_add_title").val("");
                                    jQuery("#wpgmza_add_address").val("");
                                    jQuery("#wpgmza_add_desc").val("");
                                    jQuery("#wpgmza_add_pic").val("");
                                    jQuery("#wpgmza_link_url").val("");
                                    jQuery("#wpgmza_edit_id").val("");
                                    jQuery("#wpgmza_add_retina").attr('checked',false);
                                    jQuery("#wpgmza_animation").val("None");
                                    jQuery("#wpgmza_cmm").html("");
                                    jQuery('input[name=wpgmza_cat_checkbox]').attr('checked',false);
                                    wpgmza_reinitialisetbl();
                                });

                            } else {
                                alert("<?php 
                            _e("Geocode was not successful for the following reason", "wp-google-maps");
                            ?>
: " + status);
                            }
                        });
                        } else {
                            /* address was the same, no need for geocoding */
                            var data = {
                                action: 'edit_marker',
                                security: '<?php 
                            echo $ajax_nonce;
                            ?>
',
                                map_id: wpgm_map_id,
                                edit_id: wpgm_edit_id,
                                title: wpgm_title,
                                address: wpgm_address,
                                lat: wpgm_lat,
                                lng: wpgm_lng,
                                icon: wpgm_icon,
                                retina: wpgm_retina,
                                desc: wpgm_desc,
                                link: wpgm_link,
                                pic: wpgm_pic,
                                anim: wpgm_anim,
                                category: wpgm_category,
                                infoopen: wpgm_infoopen
                            };

                            jQuery.post(ajaxurl, data, function(response) {
                                returned_data = JSON.parse(response);
                                db_marker_array = JSON.stringify(returned_data.marker_data);
                                wpgmza_InitMap();
                                jQuery("#wpgmza_marker_holder").html(JSON.parse(response).table_html);
                                jQuery("#wpgmza_addmarker_div").show();
                                jQuery("#wpgmza_editmarker_loading").hide();
                                jQuery("#wpgmza_add_title").val("");
                                jQuery("#wpgmza_add_address").val("");
                                jQuery("#wpgmza_add_desc").val("");
                                jQuery("#wpgmza_add_pic").val("");
                                jQuery("#wpgmza_link_url").val("");
                                jQuery("#wpgmza_add_retina").attr('checked',false);
                                jQuery("#wpgmza_edit_id").val("");
                                jQuery("#wpgmza_animation").val("None");
                                jQuery("#wpgmza_category").val("Select");
                                jQuery("#wpgmza_cmm").html("");
                                jQuery('input[name=wpgmza_cat_checkbox]').attr('checked',false);
                                wpgmza_reinitialisetbl();
                            });
                        }





                    });
            });

            });



            <?php 
                            if ($wpgmza_styling_enabled == "1" && $wpgmza_styling_json != "" && $wpgmza_styling_enabled != null) {
                                ?>

            var wpgmza_adv_styling_json = <?php 
                                echo html_entity_decode(stripslashes($wpgmza_styling_json));
                                ?>
;

            <?php 
                            }
                            ?>



            var MYMAP = {
                map: null,
                bounds: null,
                mc: null
            }
            MYMAP.init = function(selector, latLng, zoom) {
              var myOptions = {
                zoom:zoom,
                center: latLng,
                zoomControl: <?php 
                            if (isset($wpgmza_settings['wpgmza_settings_map_zoom']) && $wpgmza_settings['wpgmza_settings_map_zoom'] == "yes") {
                                echo "false";
                            } else {
                                echo "true";
                            }
                            ?>
,
                panControl: <?php 
                            if (isset($wpgmza_settings['wpgmza_settings_map_pan']) && $wpgmza_settings['wpgmza_settings_map_pan'] == "yes") {
                                echo "false";
                            } else {
                                echo "true";
                            }
                            ?>
,
                mapTypeControl: <?php 
                            if (isset($wpgmza_settings['wpgmza_settings_map_type']) && $wpgmza_settings['wpgmza_settings_map_type'] == "yes") {
                                echo "false";
                            } else {
                                echo "true";
                            }
                            ?>
,
                streetViewControl: <?php 
                            if (isset($wpgmza_settings['wpgmza_settings_map_streetview']) && $wpgmza_settings['wpgmza_settings_map_streetview'] == "yes") {
                                echo "false";
                            } else {
                                echo "true";
                            }
                            ?>
,
                mapTypeId: google.maps.MapTypeId.<?php 
                            echo $wpgmza_map_type;
                            ?>
              }
            <?php 
                            if ($wpgmza_styling_enabled == "1" && $wpgmza_styling_json != "" && $wpgmza_styling_enabled != null) {
                                ?>
            var WPGMZA_STYLING = new google.maps.StyledMapType(wpgmza_adv_styling_json,{name: "WPGMZA STYLING"});
            <?php 
                            }
                            ?>

            this.map = new google.maps.Map(jQuery(selector)[0], myOptions);
            

            <?php 
                            if ($wpgmza_theme_data !== false && isset($wpgmza_theme_data)) {
                                ?>
            this.map.setOptions({styles: <?php 
                                echo stripslashes($wpgmza_theme_data);
                                ?>
});
            <?php 
                            }
                            ?>
    

            <?php 
                            if ($wpgmza_styling_enabled == "1" && $wpgmza_styling_json != "" && $wpgmza_styling_enabled != null) {
                                ?>
            this.map.mapTypes.set('WPGMZA STYLING', WPGMZA_STYLING);
            this.map.setMapTypeId('WPGMZA STYLING');
            <?php 
                            }
                            ?>



            
            <?php 
                            $total_poly_array = wpgmza_b_return_polygon_id_array($_GET['map_id']);
                            if ($total_poly_array > 0) {
                                foreach ($total_poly_array as $poly_id) {
                                    $polyoptions = wpgmza_b_return_poly_options($poly_id);
                                    $linecolor = $polyoptions->linecolor;
                                    $fillcolor = $polyoptions->fillcolor;
                                    $fillopacity = $polyoptions->opacity;
                                    $lineopacity = $polyoptions->lineopacity;
                                    if (!$linecolor) {
                                        $linecolor = "000000";
                                    }
                                    if (!$fillcolor) {
                                        $fillcolor = "66FF00";
                                    }
                                    if ($fillopacity == "") {
                                        $fillopacity = "0.5";
                                    }
                                    if ($lineopacity == "") {
                                        $lineopacity = "1";
                                    }
                                    $linecolor = "#" . $linecolor;
                                    $fillcolor = "#" . $fillcolor;
                                    ?>
 
            var WPGM_PathData_<?php 
                                    echo $poly_id;
                                    ?>
 = [
                <?php 
                                    $poly_array = wpgmza_b_return_polygon_array($poly_id);
                                    foreach ($poly_array as $single_poly) {
                                        $poly_data_raw = str_replace(" ", "", $single_poly);
                                        $poly_data_raw = explode(",", $poly_data_raw);
                                        $lat = $poly_data_raw[0];
                                        $lng = $poly_data_raw[1];
                                        ?>
                    new google.maps.LatLng(<?php 
                                        echo $lat;
                                        ?>
, <?php 
                                        echo $lng;
                                        ?>
),            
                    <?php 
                                    }
                                    ?>
                
               
            ];
            var WPGM_Path_<?php 
                                    echo $poly_id;
                                    ?>
 = new google.maps.Polygon({
              path: WPGM_PathData_<?php 
                                    echo $poly_id;
                                    ?>
,
              strokeColor: "<?php 
                                    echo $linecolor;
                                    ?>
",
              strokeOpacity: "<?php 
                                    echo $lineopacity;
                                    ?>
",
              fillOpacity: "<?php 
                                    echo $fillopacity;
                                    ?>
",
              fillColor: "<?php 
                                    echo $fillcolor;
                                    ?>
",
              strokeWeight: 2
            });

            WPGM_Path_<?php 
                                    echo $poly_id;
                                    ?>
.setMap(this.map);
            <?php 
                                }
                            }
                            ?>
                
                
                
<?php 
                            // polylines
                            $total_polyline_array = wpgmza_b_return_polyline_id_array($_GET['map_id']);
                            if ($total_polyline_array > 0) {
                                foreach ($total_polyline_array as $poly_id) {
                                    $polyoptions = wpgmza_b_return_polyline_options($poly_id);
                                    $linecolor = $polyoptions->linecolor;
                                    $fillopacity = $polyoptions->opacity;
                                    $linethickness = $polyoptions->linethickness;
                                    if (!$linecolor) {
                                        $linecolor = "000000";
                                    }
                                    if (!$linethickness) {
                                        $linethickness = "4";
                                    }
                                    if (!$fillopacity) {
                                        $fillopacity = "0.5";
                                    }
                                    $linecolor = "#" . $linecolor;
                                    ?>
 
                var WPGM_PathLineData_<?php 
                                    echo $poly_id;
                                    ?>
 = [
                    <?php 
                                    $poly_array = wpgmza_b_return_polyline_array($poly_id);
                                    foreach ($poly_array as $single_poly) {
                                        $poly_data_raw = str_replace(" ", "", $single_poly);
                                        $poly_data_raw = explode(",", $poly_data_raw);
                                        $lat = $poly_data_raw[0];
                                        $lng = $poly_data_raw[1];
                                        ?>
                        new google.maps.LatLng(<?php 
                                        echo $lat;
                                        ?>
, <?php 
                                        echo $lng;
                                        ?>
),            
                        <?php 
                                    }
                                    ?>
                ];
                var WPGM_PathLine_<?php 
                                    echo $poly_id;
                                    ?>
 = new google.maps.Polyline({
                  path: WPGM_PathLineData_<?php 
                                    echo $poly_id;
                                    ?>
,
                  strokeColor: "<?php 
                                    echo $linecolor;
                                    ?>
",
                  strokeOpacity: "<?php 
                                    echo $fillopacity;
                                    ?>
",
                  strokeWeight: "<?php 
                                    echo $linethickness;
                                    ?>
"
                  
                });

                WPGM_PathLine_<?php 
                                    echo $poly_id;
                                    ?>
.setMap(this.map);
                <?php 
                                }
                            }
                            ?>
                  
                
                
            this.bounds = new google.maps.LatLngBounds();
            google.maps.event.addListener(MYMAP.map, 'zoom_changed', function() {
                zoomLevel = MYMAP.map.getZoom();

                jQuery("#wpgmza_start_zoom").val(zoomLevel);

              });
              
              google.maps.event.addListener(MYMAP.map, 'rightclick', function(event) {
                var marker = new google.maps.Marker({
                    position: event.latLng, 
                    map: MYMAP.map
                });
                marker.setDraggable(true);
                google.maps.event.addListener(marker, 'dragend', function(event) { 
                    jQuery("#wpgmza_add_address").val(event.latLng.lat()+','+event.latLng.lng());
                } );
                jQuery("#wpgmza_add_address").val(event.latLng.lat()+', '+event.latLng.lng());
                jQuery("#wpgm_notice_message_save_marker").show();
                setTimeout(function() {
                    jQuery("#wpgm_notice_message_save_marker").fadeOut('slow')
                }, 3000);
               
            });
              
            google.maps.event.addListener(MYMAP.map, 'center_changed', function() {
                var location = MYMAP.map.getCenter();
                jQuery("#wpgmza_start_location").val(location.lat()+","+location.lng());
                jQuery("#wpgmaps_save_reminder").show();
            });

            <?php 
                            if ($wpgmza_bicycle == "1") {
                                ?>
            var bikeLayer = new google.maps.BicyclingLayer();
            bikeLayer.setMap(this.map);
            <?php 
                            }
                            ?>
            <?php 
                            if ($wpgmza_traffic == "1") {
                                ?>
            var trafficLayer = new google.maps.TrafficLayer();
            trafficLayer.setMap(this.map);
            <?php 
                            }
                            ?>
            <?php 
                            if ($weather_layer == 1) {
                                ?>
            var weatherLayer = new google.maps.weather.WeatherLayer();
            weatherLayer.setMap(this.map);
            <?php 
                            }
                            ?>
            <?php 
                            if ($cloud_layer == 1) {
                                ?>
            var cloudLayer = new google.maps.weather.CloudLayer();
            cloudLayer.setMap(this.map);
            <?php 
                            }
                            ?>
            <?php 
                            if ($transport_layer == 1) {
                                ?>
            var transitLayer = new google.maps.TransitLayer();
            transitLayer.setMap(this.map);
            <?php 
                            }
                            ?>



            <?php 
                            if ($kml != "") {
                                ?>
            var georssLayer = new google.maps.KmlLayer('<?php 
                                echo $kml;
                                ?>
?tstamp=<?php 
                                echo time();
                                ?>
');
            georssLayer.setMap(this.map);
            <?php 
                            }
                            ?>
            <?php 
                            if ($fusion != "") {
                                ?>
                var fusionlayer = new google.maps.FusionTablesLayer('<?php 
                                echo $fusion;
                                ?>
', {
                      suppressInfoWindows: false
                });
                fusionlayer.setMap(this.map);
            <?php 
                            }
                            ?>



            }
            var infoWindow = new google.maps.InfoWindow();
            <?php 
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            if (isset($wpgmza_settings['wpgmza_settings_infowindow_width'])) {
                                $wpgmza_settings_infowindow_width = $wpgmza_settings['wpgmza_settings_infowindow_width'];
                            } else {
                                $wpgmza_settings_infowindow_width = "";
                            }
                            if (!$wpgmza_settings_infowindow_width || !isset($wpgmza_settings_infowindow_width)) {
                                $wpgmza_settings_infowindow_width = "200";
                            }
                            ?>
            infoWindow.setOptions({maxWidth:<?php 
                            echo $wpgmza_settings_infowindow_width;
                            ?>
});

            google.maps.event.addDomListener(window, 'resize', function() {
                var myLatLng = new google.maps.LatLng(<?php 
                            echo $wpgmza_lat;
                            ?>
,<?php 
                            echo $wpgmza_lng;
                            ?>
);
                MYMAP.map.setCenter(myLatLng);
            });



            MYMAP.placeMarkers = function(filename,map_id) {
                marker_array = [];
                if (marker_pull === '1') {
                        jQuery.get(filename, function(xml) {
                                jQuery(xml).find("marker").each(function(){
                                        var wpgmza_def_icon = '<?php 
                            echo $wpgmza_default_icon;
                            ?>
';
                                        var wpmgza_map_id = jQuery(this).find('map_id').text();

                                        if (wpmgza_map_id == map_id) {
                                            var wpmgza_title = jQuery(this).find('title').text();
                                            var wpmgza_show_address = jQuery(this).find('address').text();
                                            var wpmgza_address = jQuery(this).find('address').text();
                                            var wpmgza_mapicon = jQuery(this).find('icon').text();
                                            var wpmgza_image = jQuery(this).find('pic').text();
                                            var wpmgza_desc  = jQuery(this).find('desc').text();
                                            var wpmgza_anim  = jQuery(this).find('anim').text();
                                            var wpmgza_retina  = jQuery(this).find('retina').text();
                                            var wpmgza_infoopen  = jQuery(this).find('infoopen').text();
                                            var wpmgza_linkd = jQuery(this).find('linkd').text();
                                            if (wpmgza_title != "") {
                                                wpmgza_title = wpmgza_title+'<br />';
                                            }

                                            /* check image */
                                            if (wpmgza_image != "") {

                                        <?php 
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            if (isset($wpgmza_settings['wpgmza_settings_infowindow_link_text'])) {
                                $wpgmza_settings_infowindow_link_text = $wpgmza_settings['wpgmza_settings_infowindow_link_text'];
                            } else {
                                $wpgmza_settings_infowindow_link_text = false;
                            }
                            if (!$wpgmza_settings_infowindow_link_text) {
                                $wpgmza_settings_infowindow_link_text = __("More details", "wp-google-maps");
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_image_resizing']) && $wpgmza_settings['wpgmza_settings_image_resizing'] == 'yes') {
                                $wpgmza_image_resizing = true;
                            } else {
                                $wpgmza_image_resizing = false;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_use_timthumb'])) {
                                $wpgmza_use_timthumb = $wpgmza_settings['wpgmza_settings_use_timthumb'];
                            } else {
                                $wpgmza_use_timthumb = true;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_image_height'])) {
                                $wpgmza_image_height = $wpgmza_settings['wpgmza_settings_image_height'];
                            } else {
                                $wpgmza_image_height = false;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_image_width'])) {
                                $wpgmza_image_width = $wpgmza_settings['wpgmza_settings_image_width'];
                            } else {
                                $wpgmza_image_width = false;
                            }
                            if (!$wpgmza_image_height || !isset($wpgmza_image_height)) {
                                $wpgmza_image_height = "100";
                            }
                            if (!$wpgmza_image_width || !isset($wpgmza_image_width)) {
                                $wpgmza_image_width = "100";
                            }
                            /* check if using timthumb */
                            /* timthumb completely removed in 3.29
                               if (!isset($wpgmza_use_timthumb) || $wpgmza_use_timthumb == "" || $wpgmza_use_timthumb == 1) { ?>
                                   wpmgza_image = "<img src='<?php echo wpgmaps_get_plugin_url(); ?>/timthumb.php?src="+wpmgza_image+"&h=<?php echo $wpgmza_image_height; ?>&w=<?php echo $wpgmza_image_width; ?>&zc=1' title='' alt='' style=\"float:right; width:"+<?php echo $wpgmza_image_width; ?>+"px; height:"+<?php echo $wpgmza_image_height; ?>+"px;\" />";
                               <?php } else { 
                               */
                            /* User has chosen not to use timthumb. excellent! */
                            if ($wpgmza_image_resizing) {
                                ?>
                                                    wpgmza_resize_string = "width='<?php 
                                echo $wpgmza_image_width;
                                ?>
' height='<?php 
                                echo $wpgmza_image_height;
                                ?>
'";
                                                    <?php 
                            } else {
                                ?>
                                                    wpgmza_resize_string = "";
                                                    <?php 
                            }
                            ?>
                                                
                                                wpmgza_image = "<img src='"+wpmgza_image+"' class='wpgmza_map_image wpgmza_map_image_"+wpmgza_map_id+"' style='float:right;' "+wpgmza_resize_string+" />";




                                            <?php 
                            /* } */
                            ?>

                                            /* end check image */
                                            } else { wpmgza_image = "" }

                                            <?php 
                            if (isset($wpgmza_settings['wpgmza_settings_retina_width'])) {
                                $wpgmza_settings_retina_width = intval($wpgmza_settings['wpgmza_settings_retina_width']);
                            } else {
                                $wpgmza_settings_retina_width = 31;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_retina_height'])) {
                                $wpgmza_settings_retina_height = intval($wpgmza_settings['wpgmza_settings_retina_height']);
                            } else {
                                $wpgmza_settings_retina_height = 45;
                            }
                            ?>

                                            if (wpmgza_linkd != "") {
                                                    <?php 
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            if (isset($wpgmza_settings['wpgmza_settings_infowindow_links'])) {
                                $wpgmza_settings_infowindow_links = $wpgmza_settings['wpgmza_settings_infowindow_links'];
                            }
                            if (isset($wpgmza_settings_infowindow_links) && $wpgmza_settings_infowindow_links == "yes") {
                                $wpgmza_settings_infowindow_links = "target='_BLANK'";
                            } else {
                                $wpgmza_settings_infowindow_links = "";
                            }
                            ?>

                                                    wpmgza_linkd = "<a href='"+wpmgza_linkd+"' <?php 
                            echo $wpgmza_settings_infowindow_links;
                            ?>
 title='<?php 
                            echo $wpgmza_settings_infowindow_link_text;
                            ?>
'><?php 
                            echo $wpgmza_settings_infowindow_link_text;
                            ?>
</a>";
                                                }
                                            if (wpmgza_mapicon == "" || !wpmgza_mapicon) { if (wpgmza_def_icon != "") { wpmgza_mapicon = '<?php 
                            echo $wpgmza_default_icon;
                            ?>
'; } }
                                            var wpgmza_optimized = true;
                                            if (wpmgza_retina === "1" && wpmgza_mapicon !== "") {
                                                wpmgza_mapicon = new google.maps.MarkerImage(wpmgza_mapicon, null, null, null, new google.maps.Size(<?php 
                            echo $wpgmza_settings_retina_width;
                            ?>
,<?php 
                            echo $wpgmza_settings_retina_height;
                            ?>
));
                                                wpgmza_optimized = false;
                                            }
                                            var lat = jQuery(this).find('lat').text();
                                            var lng = jQuery(this).find('lng').text();
                                            var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
                                            MYMAP.bounds.extend(point);
                                            if (wpmgza_anim == "1") {
                                            var marker = new google.maps.Marker({
                                                    position: point,
                                                    map: MYMAP.map,
                                                    icon: wpmgza_mapicon,
                                                    animation: google.maps.Animation.BOUNCE
                                            });
                                            }
                                            else if (wpmgza_anim == "2") {
                                                var marker = new google.maps.Marker({
                                                        position: point,
                                                        map: MYMAP.map,
                                                        icon: wpmgza_mapicon,
                                                        animation: google.maps.Animation.DROP
                                                });
                                            }
                                            else {
                                                var marker = new google.maps.Marker({
                                                        position: point,
                                                        map: MYMAP.map,
                                                        icon: wpmgza_mapicon
                                                });
                                            }
                                            //var html=''+wpmgza_image+'<strong>'+wpmgza_address+'</strong><br /><span style="font-size:12px;">'+wpmgza_desc+'<br />'+wpmgza_linkd+'</span>';
                                            <?php 
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            if (isset($wpgmza_settings['wpgmza_settings_infowindow_address'])) {
                                $wpgmza_settings_infowindow_address = $wpgmza_settings['wpgmza_settings_infowindow_address'];
                            } else {
                                $wpgmza_settings_infowindow_address = "";
                            }
                            if ($wpgmza_settings_infowindow_address == "yes") {
                                ?>
                                                        wpmgza_show_address = "";
                                            <?php 
                            }
                            ?>


                                            var html='<div id="wpgmza_markerbox" style="min-width:'+<?php 
                            echo $wpgmza_settings_infowindow_width;
                            ?>
+'px;">'+wpmgza_image+'<p><strong>'+wpmgza_title+'</strong>'+wpmgza_show_address+'<br />'
                                                    +wpmgza_desc+
                                                    '<br />'
                                                    +wpmgza_linkd+
                                                    ''
                                                    +'</p></div>';
                                            if (wpmgza_infoopen == "1") {

                                                infoWindow.setContent(html);
                                                infoWindow.open(MYMAP.map, marker);
                                            }

                                            <?php 
                            if (isset($wpgmza_open_infowindow_by) && $wpgmza_open_infowindow_by == '2') {
                                ?>
                                            google.maps.event.addListener(marker, 'mouseover', function() {
                                                infoWindow.close();
                                                infoWindow.setContent(html);
                                                infoWindow.open(MYMAP.map, marker);

                                            });
                                            <?php 
                            } else {
                                ?>
                                            google.maps.event.addListener(marker, 'click', function() {
                                                infoWindow.close();
                                                infoWindow.setContent(html);
                                                infoWindow.open(MYMAP.map, marker);

                                            });
                                            <?php 
                            }
                            ?>


                                        }

                            });
                    });
                
                } else {
                    
                    if (db_marker_array.length > 0) {
                    var dec_marker_array = jQuery.parseJSON(db_marker_array);
                    jQuery.each(dec_marker_array, function(i, val) {


                        var wpgmza_def_icon = '<?php 
                            echo $wpgmza_default_icon;
                            ?>
';
                        var wpmgza_map_id = val.map_id;

                        if (wpmgza_map_id == map_id) {
                            var wpmgza_title = val.title;
                            var wpmgza_show_address = val.address;
                            var wpmgza_address = val.address;
                            var wpmgza_mapicon = val.icon;
                            var wpmgza_image = val.pic;
                            var wpmgza_desc  = val.desc;
                            var wpmgza_anim  = val.anim;
                            var wpmgza_retina  = val.retina;
                            var wpmgza_infoopen  = val.infoopen;
                            var wpmgza_linkd = val.linkd;
                            if (wpmgza_title != "") {
                                wpmgza_title = wpmgza_title+'<br />';
                            }
                           /* check image */
                            if (wpmgza_image != "") {

                        <?php 
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            if (isset($wpgmza_settings['wpgmza_settings_infowindow_link_text'])) {
                                $wpgmza_settings_infowindow_link_text = $wpgmza_settings['wpgmza_settings_infowindow_link_text'];
                            } else {
                                $wpgmza_settings_infowindow_link_text = false;
                            }
                            if (!$wpgmza_settings_infowindow_link_text) {
                                $wpgmza_settings_infowindow_link_text = __("More details", "wp-google-maps");
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_image_resizing']) && $wpgmza_settings['wpgmza_settings_image_resizing'] == 'yes') {
                                $wpgmza_image_resizing = true;
                            } else {
                                $wpgmza_image_resizing = false;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_use_timthumb'])) {
                                $wpgmza_use_timthumb = $wpgmza_settings['wpgmza_settings_use_timthumb'];
                            } else {
                                $wpgmza_use_timthumb = true;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_image_height'])) {
                                $wpgmza_image_height = $wpgmza_settings['wpgmza_settings_image_height'];
                            } else {
                                $wpgmza_image_height = false;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_image_width'])) {
                                $wpgmza_image_width = $wpgmza_settings['wpgmza_settings_image_width'];
                            } else {
                                $wpgmza_image_width = false;
                            }
                            if (!$wpgmza_image_height || !isset($wpgmza_image_height)) {
                                $wpgmza_image_height = "100";
                            }
                            if (!$wpgmza_image_width || !isset($wpgmza_image_width)) {
                                $wpgmza_image_width = "100";
                            }
                            /* check if using timthumb */
                            /* timthumb completely removed in 3.29
                               if (!isset($wpgmza_use_timthumb) || $wpgmza_use_timthumb == "" || $wpgmza_use_timthumb == 1) { ?>
                                   wpmgza_image = "<img src='<?php echo wpgmaps_get_plugin_url(); ?>/timthumb.php?src="+wpmgza_image+"&h=<?php echo $wpgmza_image_height; ?>&w=<?php echo $wpgmza_image_width; ?>&zc=1' title='' alt='' style=\"float:right; width:"+<?php echo $wpgmza_image_width; ?>+"px; height:"+<?php echo $wpgmza_image_height; ?>+"px;\" />";
                               <?php } else { 
                               */
                            /* User has chosen not to use timthumb. excellent! */
                            if ($wpgmza_image_resizing) {
                                ?>
                                    wpgmza_resize_string = "width='<?php 
                                echo $wpgmza_image_width;
                                ?>
' height='<?php 
                                echo $wpgmza_image_height;
                                ?>
'";
                                    <?php 
                            } else {
                                ?>
                                    wpgmza_resize_string = "";
                                    <?php 
                            }
                            ?>
                                
                                wpmgza_image = "<img src='"+wpmgza_image+"' class='wpgmza_map_image wpgmza_map_image_"+wpmgza_map_id+"' style='float:right;' "+wpgmza_resize_string+" />";




                            <?php 
                            /* } */
                            ?>

                            /* end check image */
                            } else { wpmgza_image = "" }

                            <?php 
                            if (isset($wpgmza_settings['wpgmza_settings_retina_width'])) {
                                $wpgmza_settings_retina_width = intval($wpgmza_settings['wpgmza_settings_retina_width']);
                            } else {
                                $wpgmza_settings_retina_width = 31;
                            }
                            if (isset($wpgmza_settings['wpgmza_settings_retina_height'])) {
                                $wpgmza_settings_retina_height = intval($wpgmza_settings['wpgmza_settings_retina_height']);
                            } else {
                                $wpgmza_settings_retina_height = 45;
                            }
                            ?>
                            if (wpmgza_linkd != "") {
                                    <?php 
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            if (isset($wpgmza_settings['wpgmza_settings_infowindow_links'])) {
                                $wpgmza_settings_infowindow_links = $wpgmza_settings['wpgmza_settings_infowindow_links'];
                            }
                            if (isset($wpgmza_settings_infowindow_links) && $wpgmza_settings_infowindow_links == "yes") {
                                $wpgmza_settings_infowindow_links = "target='_BLANK'";
                            } else {
                                $wpgmza_settings_infowindow_links = "";
                            }
                            ?>

                                    wpmgza_linkd = "<a href='"+wpmgza_linkd+"' <?php 
                            echo $wpgmza_settings_infowindow_links;
                            ?>
 title='<?php 
                            echo $wpgmza_settings_infowindow_link_text;
                            ?>
'><?php 
                            echo $wpgmza_settings_infowindow_link_text;
                            ?>
</a>";
                                }
                            if (wpmgza_mapicon == "" || !wpmgza_mapicon) { if (wpgmza_def_icon != "") { wpmgza_mapicon = '<?php 
                            echo $wpgmza_default_icon;
                            ?>
'; } }
                            var wpgmza_optimized = true;
                            if (wpmgza_retina === "1" && wpmgza_mapicon !== "") {
                                wpmgza_mapicon = new google.maps.MarkerImage(wpmgza_mapicon, null, null, null, new google.maps.Size(<?php 
                            echo $wpgmza_settings_retina_width;
                            ?>
,<?php 
                            echo $wpgmza_settings_retina_height;
                            ?>
));
                                wpgmza_optimized = false;
                            }
                            var lat = val.lat;
                            var lng = val.lng;
                            var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
                            MYMAP.bounds.extend(point);
                            if (wpmgza_anim == "1") {
                            var marker = new google.maps.Marker({
                                    position: point,
                                    map: MYMAP.map,
                                    icon: wpmgza_mapicon,
                                    animation: google.maps.Animation.BOUNCE
                            });
                            }
                            else if (wpmgza_anim == "2") {
                                var marker = new google.maps.Marker({
                                        position: point,
                                        map: MYMAP.map,
                                        icon: wpmgza_mapicon,
                                        animation: google.maps.Animation.DROP
                                });
                            }
                            else {
                                var marker = new google.maps.Marker({
                                        position: point,
                                        map: MYMAP.map,
                                        icon: wpmgza_mapicon
                                });
                            }
                            //var html=''+wpmgza_image+'<strong>'+wpmgza_address+'</strong><br /><span style="font-size:12px;">'+wpmgza_desc+'<br />'+wpmgza_linkd+'</span>';
                            <?php 
                            $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS");
                            if (isset($wpgmza_settings['wpgmza_settings_infowindow_address'])) {
                                $wpgmza_settings_infowindow_address = $wpgmza_settings['wpgmza_settings_infowindow_address'];
                            } else {
                                $wpgmza_settings_infowindow_address = "";
                            }
                            if ($wpgmza_settings_infowindow_address == "yes") {
                                ?>
                                        wpmgza_show_address = "";
                            <?php 
                            }
                            ?>

                            var html='<div id="wpgmza_markerbox" style="min-width:'+<?php 
                            echo $wpgmza_settings_infowindow_width;
                            ?>
+'px;">'+wpmgza_image+'<p><strong>'+wpmgza_title+'</strong>'+wpmgza_show_address+'<br />'
                                    +wpmgza_desc+
                                    '<br />'
                                    +wpmgza_linkd+
                                    ''
                                    +'</p></div>';
                            if (wpmgza_infoopen == "1") {

                                infoWindow.setContent(html);
                                infoWindow.open(MYMAP.map, marker);
                            }

                            <?php 
                            if (isset($wpgmza_open_infowindow_by) && $wpgmza_open_infowindow_by == '2') {
                                ?>
                            google.maps.event.addListener(marker, 'mouseover', function() {
                                infoWindow.close(); 
                               infoWindow.setContent(html);
                                infoWindow.open(MYMAP.map, marker);

                            });
                            <?php 
                            } else {
                                ?>
                            google.maps.event.addListener(marker, 'click', function() {
                                infoWindow.close();
                                infoWindow.setContent(html);
                                infoWindow.open(MYMAP.map, marker);
                            });
                            <?php 
                            }
                            ?>
                        }
                  });
                    var mcOptions = {
                        gridSize: 50,
                        maxZoom: 15
                    };
                   
                  }
                }
            }


            

        </script>
        <script type="text/javascript" src="<?php 
                            echo wpgmaps_get_plugin_url();
                            ?>
/js/wpgmaps.js"></script>
<?php 
                        }
                    }
                }
            }
        }
    }
}
function wpgmza_pro_category_edit_layout($cat_id)
{
    global $wpdb;
    global $wpgmza_tblname_categories;
    $map_ids = wpgmza_return_all_map_ids();
    $results = $wpdb->get_results("\r\n      SELECT *\r\n      FROM {$wpgmza_tblname_categories}\r\n      WHERE `id` = '{$cat_id}' LIMIT 1\r\n    ");
    if (isset($results[0]->category_icon) && $results[0]->category_icon != '') {
        $display_marker = "<img src='" . $results[0]->category_icon . "' />";
        $display_url = $results[0]->category_icon;
    } else {
        $display_marker = "<img src=\"" . wpgmaps_get_plugin_url() . "/images/marker.png\" />";
        $display_url = "";
    }
    if (isset($results[0]->retina) && intval($results[0]->retina) == 1) {
        $retina_checked = "checked='checked'";
    } else {
        $retina_checked = "";
    }
    echo "<div class='wrap'>";
    echo "  <h1>WP Google Maps</h1>";
    echo "  <div class='wide'>";
    echo "      <h2>" . __("Add a Marker Category", "wp-google-maps") . "</h2>";
    echo "      <form action='admin.php?page=wp-google-maps-menu-categories' method='post' id='wpgmaps_add_marker_category' name='wpgmaps_edit_marker_category_form'>";
    echo "      <table>";
    echo "          <tr>";
    echo "              <td><strong>" . __("Category Name", "wp-google-maps") . "</strong>:</td>";
    echo "              <td><input type='hidden' name='wpgmaps_marker_category_id' id='wpgmaps_marker_category_id' value='" . $results[0]->id . "' /><input type='text' name='wpgmaps_marker_category_name' id='wpgmaps_marker_category_name' value='" . $results[0]->category_name . "' /></td>";
    echo "              <td></td>";
    echo "          </tr>";
    echo "          <tr style='height:20px;'>";
    echo "              <td></td>";
    echo "              <td></td>";
    echo "              <td></td>";
    echo "          </tr>";
    echo "          <tr valign='top'>";
    echo "              <td valign='middle'><strong>" . __("Category Marker", "wp-google-maps") . "</strong>:</td>";
    echo "              <td align='left'><span id=\"wpgmza_mm\">{$display_marker}</span> </td>";
    echo "              <td valign='middle'>Enter URL <input id=\"upload_default_category_marker\" name=\"upload_default_category_marker\" type='text' size='35' class='regular-text' maxlength='700' value='{$display_url}' /> or <input id=\"upload_default_category_marker_btn\" type=\"button\" value=\"" . __("Upload Image", "wp-google-maps") . "\" /> <a href=\"javascript:void(0);\" onClick=\"document.forms['wpgmaps_edit_marker_category_form'].upload_default_category_marker.value = ''; var span = document.getElementById('wpgmza_mm'); while( span.firstChild ) { span.removeChild( span.firstChild ); } span.appendChild( document.createTextNode('')); return false;\" title=\"Reset to default\">-reset-</a> <small><i>" . __("Get great map markers <a href='http://mapicons.nicolasmollet.com/' target='_BLANK' title='Great Google Map Markers'>here</a>", "wp-google-maps") . "</i></small></td>";
    echo "          </tr>";
    echo "          <tr>";
    echo "              <td><strong>" . __("Retina Ready", "wp-google-maps") . "</strong>:</td>";
    echo "              <td><input type='checkbox' name='wpgmaps_marker_category_retina' value='1' {$retina_checked}>" . __("This marker is a retina-ready marker", "wp-google-maps") . "</td>";
    echo "              <td></td>";
    echo "          </tr>";
    echo "          <tr style='height:20px;'>";
    echo "              <td></td>";
    echo "              <td></td>";
    echo "              <td></td>";
    echo "          </tr>";
    echo "          <tr>";
    echo "              <td valign='top'><strong>" . __("Assigned to ", "wp-google-maps") . "</strong>:</td>";
    echo "              <td>";
    echo "                  <input type='checkbox' name='assigned_to_map[]' value='ALL' " . wpgmza_check_cat_map('ALL', $cat_id) . "> All Maps <br /><br />";
    foreach ($map_ids as $map_id) {
        $map_data = wpgmza_get_map_data($map_id);
        echo "                  <input type='checkbox' name='assigned_to_map[]' value='" . $map_id . "' " . wpgmza_check_cat_map($map_id, $cat_id) . "> " . $map_data->map_title . "  (id " . $map_id . ")<br />";
    }
    echo "              </td>";
    echo "          </tr>";
    echo "      </table>";
    echo "          <p class='submit'><input type='submit' name='wpgmza_edit_marker_category' class='button-primary' value='" . __("Save Category", "wp-google-maps") . " &raquo;' /></p>";
    echo "      </form>";
    echo "  </div>";
    echo "</div>";
}
function wpgmza_pro_advanced_menu()
{
    $wpgmza_csv = "<a href=\"" . wpgmaps_get_plugin_url() . "/csv.php\" title=\"" . __("Download ALL marker data to a CSV file", "wp-google-maps") . "\">" . __("Download ALL marker data to a CSV file", "wp-google-maps") . "</a>";
    echo "\n        <div class=\"wrap\"><div id=\"icon-tools\" class=\"icon32 icon32-posts-post\"><br></div><h2>" . __("Advanced Options", "wp-google-maps") . "</h2>\n        <div style=\"display:block; overflow:auto; background-color:#FFFBCC; padding:10px; border:1px solid #E6DB55; margin-top:35px; margin-bottom:5px;\">\n            {$wpgmza_csv}\n            <br /><br /><strong>- " . __("OR", "wp-google-maps") . " -<br /><br /></strong><form enctype=\"multipart/form-data\" method=\"POST\">\n                " . __("Upload CSV File", "wp-google-maps") . ": <input name=\"wpgmza_csvfile\" type=\"file\" /><br />\n                <input name=\"wpgmza_security\" type=\"hidden\" value=\"{$wpgmza_post_nonce}\" /><br />\n                " . __("Replace existing data with data in file", "wp-google-maps") . ": <input name=\"wpgmza_csvreplace\" type=\"checkbox\" value=\"Yes\" /><br />\n                <input type=\"submit\" name=\"wpgmza_uploadcsv_btn\" value=\"" . __("Upload File", "wp-google-maps") . "\" />\n            </form>\n        </div>\n\n\n\n    ";
}
Exemple #8
0
function wpgmza_return_marker_list($map_id)
{
    wpgmaps_debugger("return_marker_start");
    global $wpdb;
    global $wpgmza_tblname;
    $marker_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpgmza_tblname} WHERE `map_id` = '{$map_id}';"));
    if ($marker_count > 2000) {
        return __("There are too many markers to make use of the live edit function. The maximum amount for this functionality is 2000 markers. Anything more than that number would crash your browser. In order to edit your markers, you would need to download the table in CSV format, edit it and re-upload it.", "wp-google-maps");
    } else {
        $results = $wpdb->get_results("\n\tSELECT *\n\tFROM {$wpgmza_tblname}\n\tWHERE `map_id` = '{$map_id}' ORDER BY `id` DESC\n    ");
        $wpgmza_tmp .= "\n        <table id=\"wpgmza_table\" class=\"display\" cellspacing=\"0\" cellpadding=\"0\">\n        <thead>\n        <tr>\n            <th><strong>" . __("ID", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Icon", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Title", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Address", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Description", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Image", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Link", "wp-google-maps") . "</strong></th>\n            <th><strong>" . __("Action", "wp-google-maps") . "</strong></th>\n        </tr>\n        </thead>\n        <tbody>\n";
        $wpgmza_data = get_option('WPGMZA');
        if ($wpgmza_data['map_default_marker']) {
            $default_icon = "<img src='" . $wpgmza_data['map_default_marker'] . "' />";
        } else {
            $default_icon = "<img src='" . wpgmaps_get_plugin_url() . "/images/marker.png' />";
        }
        foreach ($results as $result) {
            $img = $result->pic;
            $link = $result->link;
            $icon = $result->icon;
            if (!$img) {
                $pic = "";
            } else {
                $pic = "<img src=\"" . $result->pic . "\" width=\"40\" />";
            }
            if (!$icon) {
                $icon = $default_icon;
            } else {
                $icon = "<img src='" . $result->icon . "' />";
            }
            if (!$link) {
                $linktd = "";
            } else {
                $linktd = "<a href=\"" . $result->link . "\" target=\"_BLANK\" title=\"" . __("View this link", "wp-google-maps") . "\">&gt;&gt;</a>";
            }
            $wpgmza_tmp .= "\n            <tr id=\"wpgmza_tr_" . $result->id . "\">\n                <td height=\"40\">" . $result->id . "</td>\n                <td height=\"40\">" . $icon . "<input type=\"hidden\" id=\"wpgmza_hid_marker_icon_" . $result->id . "\" value=\"" . $result->icon . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_anim_" . $result->id . "\" value=\"" . $result->anim . "\" /><input type=\"hidden\" id=\"wpgmza_hid_marker_infoopen_" . $result->id . "\" value=\"" . $result->infoopen . "\" /></td>\n                <td>" . $result->title . "<input type=\"hidden\" id=\"wpgmza_hid_marker_title_" . $result->id . "\" value=\"" . $result->title . "\" /></td>\n                <td>" . $result->address . "<input type=\"hidden\" id=\"wpgmza_hid_marker_address_" . $result->id . "\" value=\"" . $result->address . "\" /></td>\n                <td>" . $result->desc . "<input type=\"hidden\" id=\"wpgmza_hid_marker_desc_" . $result->id . "\" value=\"" . $result->desc . "\" /></td>\n                <td>{$pic}<input type=\"hidden\" id=\"wpgmza_hid_marker_pic_" . $result->id . "\" value=\"" . $result->pic . "\" /></td>\n                <td>{$linktd}<input type=\"hidden\" id=\"wpgmza_hid_marker_link_" . $result->id . "\" value=\"" . $result->link . "\" /></td>\n                <td width='170' align='center'>\n                    <a href=\"#wpgmaps_marker\" title=\"" . __("Edit this marker", "wp-google-maps") . "\" class=\"wpgmza_edit_btn\" id=\"" . $result->id . "\">" . __("Edit", "wp-google-maps") . "</a> |\n                    <a href=\"?page=wp-google-maps-menu&action=edit_marker&id=" . $result->id . "\" title=\"" . __("Edit this marker", "wp-google-maps") . "\" class=\"wpgmza_edit_btn\" id=\"" . $result->id . "\">" . __("Edit Location", "wp-google-maps") . "</a> |\n                    <a href=\"javascript:void(0);\" title=\"" . __("Delete this marker", "wp-google-maps") . "\" class=\"wpgmza_del_btn\" id=\"" . $result->id . "\">" . __("Delete", "wp-google-maps") . "</a>\n                </td>\n            </tr>";
        }
        $wpgmza_tmp .= "</tbody></table>";
        wpgmaps_debugger("return_marker_end");
        return $wpgmza_tmp;
    }
}