function wpgmaps_user_javascript_basic() { global $short_code_active; global $wpgmza_current_map_id; if ($short_code_active) { $ajax_nonce = wp_create_nonce("wpgmza"); $res = wpgmza_get_map_data($wpgmza_current_map_id); $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); $api_version = $wpgmza_settings['wpgmza_api_version']; if (isset($api_version) && $api_version != "") { $api_version_string = "v={$api_version}&"; } else { $api_version_string = "v=3.14&"; } $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 = false; } 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 = false; } if (isset($map_other_settings['cloud_layer'])) { $cloud_layer = $map_other_settings['cloud_layer']; } else { $cloud_layer = false; } if (isset($map_other_settings['transport_layer'])) { $transport_layer = $map_other_settings['transport_layer']; } else { $transport_layer = false; } if (isset($map_other_settings['store_locator_bounce'])) { $store_locator_bounce = $map_other_settings['store_locator_bounce']; } else { $store_locator_bounce = 1; } $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_traffic = $res->traffic; $wpgmza_bicycle = $res->bicycle; $wpgmza_open_infowindow_by = $wpgmza_settings['wpgmza_settings_map_open_marker_by']; if ($wpgmza_open_infowindow_by == null || !isset($wpgmza_open_infowindow_by)) { $wpgmza_open_infowindow_by = '1'; } 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"; } 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") { $markers = json_encode(wpgmaps_return_markers($wpgmza_current_map_id)); } ?> <?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 } ?> <script type="text/javascript" > var marker_pull = '<?php echo $marker_pull; ?> '; var db_marker_array = '<?php echo $markers; ?> '; if ('undefined' === typeof window.jQuery) { document.getElementById('wpgmza_map').innerHTML = 'Error: In order for WP Google Maps to work, jQuery must be installed. A check was done and jQuery was not present. Please see the <a href="http://www.wpgmaps.com/documentation/troubleshooting/jquery-troubleshooting/" title="WP Google Maps - jQuery Troubleshooting">jQuery troubleshooting section of our site</a> for more information.'; } else { // all good.. continue... } jQuery(function() { jQuery(document).ready(function(){ if (/1\.(0|1|2|3|4|5|6|7)\.(0|1|2|3|4|5|6|7|8|9)/.test(jQuery.fn.jquery)) { document.getElementById('wpgmza_map').innerHTML = 'Error: Your version of jQuery is outdated. WP Google Maps requires jQuery version 1.7+ to function correctly. Go to Maps->Settings and check the box that allows you to over-ride your current jQuery to try eliminate this problem.'; } else { jQuery("#wpgmza_map").css({ height:'<?php echo $wpgmza_height; echo $wpgmza_height_type; ?> ', width:'<?php echo $wpgmza_width; echo $wpgmza_width_type; ?> ' }); 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($wpgmza_current_map_id); ?> ?u='+UniqueCode,<?php echo $wpgmza_current_map_id; ?> ,null,null,null); jQuery('body').on('tabsactivate', function(event, ui) { MYMAP.init('#wpgmza_map', myLatLng, <?php echo $start_zoom; ?> ); UniqueCode=Math.round(Math.random()*10000); MYMAP.placeMarkers('<?php echo wpgmaps_get_marker_url($wpgmza_current_map_id); ?> ?u='+UniqueCode,<?php echo $wpgmza_current_map_id; ?> ,null,null,null); }); } }); }); var MYMAP = { map: null, bounds: 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"; } ?> , draggable: <?php if (isset($wpgmza_settings['wpgmza_settings_map_draggable']) && $wpgmza_settings['wpgmza_settings_map_draggable'] == "yes") { echo "false"; } else { echo "true"; } ?> , disableDoubleClickZoom: <?php if (isset($wpgmza_settings['wpgmza_settings_map_clickzoom']) && $wpgmza_settings['wpgmza_settings_map_clickzoom'] == "yes") { echo "true"; } else { echo "false"; } ?> , scrollwheel: <?php if (isset($wpgmza_settings['wpgmza_settings_map_scroll']) && $wpgmza_settings['wpgmza_settings_map_scroll'] == "yes") { echo "false"; } else { echo "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(); <?php $total_poly_array = wpgmza_b_return_polygon_id_array($wpgmza_current_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; $lineopacity = $polyoptions->lineopacity; $fillcolor = $polyoptions->fillcolor; $fillopacity = $polyoptions->opacity; if (!$linecolor) { $linecolor = "000000"; } if (!$fillcolor) { $fillcolor = "66FF00"; } if ($lineopacity == "") { $lineopacity = "1.0"; } if ($fillopacity == "") { $fillopacity = "0.5"; } $linecolor = "#" . $linecolor; $fillcolor = "#" . $fillcolor; $poly_array = wpgmza_b_return_polygon_array($poly_id); ?> <?php if (sizeof($poly_array) > 1) { ?> var WPGM_PathData_<?php echo $poly_id; ?> = [ <?php 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 } ?> <?php // polylines $total_polyline_array = wpgmza_b_return_polyline_id_array($wpgmza_current_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) { ?> 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 (isset($wpgmza_bicycle) && $wpgmza_bicycle == "1") { ?> var bikeLayer = new google.maps.BicyclingLayer(); bikeLayer.setMap(this.map); <?php } ?> <?php if (isset($wpgmza_traffic) && $wpgmza_traffic == "1") { ?> var trafficLayer = new google.maps.TrafficLayer(); trafficLayer.setMap(this.map); <?php } ?> <?php if (isset($weather_layer) && $weather_layer == 1) { ?> <?php if ($weather_layer_temp_type == 2) { ?> var weatherLayer = new google.maps.weather.WeatherLayer({ temperatureUnits: google.maps.weather.TemperatureUnit.FAHRENHEIT }); weatherLayer.setMap(MYMAP.map); <?php } else { ?> var weatherLayer = new google.maps.weather.WeatherLayer({ temperatureUnits: google.maps.weather.TemperatureUnit.CELSIUS }); weatherLayer.setMap(MYMAP.map); <?php } ?> <?php } ?> <?php if (isset($cloud_layer) && $cloud_layer == 1) { ?> var cloudLayer = new google.maps.weather.CloudLayer(); cloudLayer.setMap(MYMAP.map); <?php } ?> <?php if (isset($transport_layer) && $transport_layer == 1) { ?> var transitLayer = new google.maps.TransitLayer(); transitLayer.setMap(MYMAP.map); <?php } ?> google.maps.event.addListener(MYMAP.map, 'click', function() { infoWindow.close(); }); } var infoWindow = new google.maps.InfoWindow(); <?php $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); $wpgmza_settings_infowindow_width = "250"; if (isset($wpgmza_settings['wpgmza_settings_infowindow_width'])) { $wpgmza_settings_infowindow_width = $wpgmza_settings['wpgmza_settings_infowindow_width']; } if (!isset($wpgmza_settings_infowindow_width) || !$wpgmza_settings_infowindow_width) { $wpgmza_settings_infowindow_width = "250"; } ?> 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,radius,searched_center,distance_type) { var check1 = 0; if (marker_pull === '1') { jQuery.get(filename, function(xml){ jQuery(xml).find("marker").each(function(){ var wpmgza_map_id = jQuery(this).find('map_id').text(); if (wpmgza_map_id == map_id) { var wpmgza_address = jQuery(this).find('address').text(); var lat = jQuery(this).find('lat').text(); var lng = jQuery(this).find('lng').text(); var wpmgza_anim = jQuery(this).find('anim').text(); var wpmgza_infoopen = jQuery(this).find('infoopen').text(); var current_lat = jQuery(this).find('lat').text(); var current_lng = jQuery(this).find('lng').text(); var show_marker_radius = true; if (radius !== null) { if (check1 > 0 ) { } else { var point = new google.maps.LatLng(parseFloat(searched_center.lat()),parseFloat(searched_center.lng())); MYMAP.bounds.extend(point); <?php if ($store_locator_bounce == 1) { ?> var marker = new google.maps.Marker({ position: point, map: MYMAP.map, animation: google.maps.Animation.BOUNCE }); <?php } else { /* dont show icon */ ?> <?php } ?> if (distance_type === "1") { var populationOptions = { strokeColor: '#FF0000', strokeOpacity: 0.25, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.15, map: MYMAP.map, center: point, radius: parseInt(radius / 0.000621371) }; } else { var populationOptions = { strokeColor: '#FF0000', strokeOpacity: 0.25, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.15, map: MYMAP.map, center: point, radius: parseInt(radius / 0.001) }; } // Add the circle for this city to the map. cityCircle = new google.maps.Circle(populationOptions); check1 = check1 + 1; } var R = 0; if (distance_type === "1") { R = 3958.7558657440545; // Radius of earth in Miles } else { R = 6378.16; // Radius of earth in kilometers } var dLat = toRad(searched_center.lat()-current_lat); var dLon = toRad(searched_center.lng()-current_lng); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(toRad(current_lat)) * Math.cos(toRad(searched_center.lat())) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; //alert("distance: "+d); if (d < radius) { show_marker_radius = true; } else { show_marker_radius = false; } } var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng)); MYMAP.bounds.extend(point); if (show_marker_radius === true) { if (wpmgza_anim === "1") { var marker = new google.maps.Marker({ position: point, map: MYMAP.map, animation: google.maps.Animation.BOUNCE }); } else if (wpmgza_anim === "2") { var marker = new google.maps.Marker({ position: point, map: MYMAP.map, animation: google.maps.Animation.DROP }); } else { var marker = new google.maps.Marker({ position: point, map: MYMAP.map }); } var d_string = ""; if (radius !== null) { if (distance_type === "1") { d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+"<?php _e("miles away", "wp-google-maps"); ?> </p>"; } else { d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+"<?php _e("km away", "wp-google-maps"); ?> </p>"; } } else { d_string = ''; } var html='<p style=\'min-width:100px; display:block;\'>'+wpmgza_address+'</p>'+d_string; if (wpmgza_infoopen === "1") { infoWindow.setContent(html); infoWindow.open(MYMAP.map, marker); } <?php if ($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 { var dec_marker_array = jQuery.parseJSON(db_marker_array); jQuery.each(dec_marker_array, function(i, val) { var wpmgza_map_id = val.map_id; if (wpmgza_map_id == map_id) { var wpmgza_address = val.address; var wpmgza_anim = val.anim; var wpmgza_infoopen = val.infoopen; var lat = val.lat; var lng = val.lng; var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng)); var current_lat = val.lat; var current_lng = val.lng; var show_marker_radius = true; if (radius !== null) { if (check1 > 0 ) { } else { var point = new google.maps.LatLng(parseFloat(searched_center.lat()),parseFloat(searched_center.lng())); MYMAP.bounds.extend(point); <?php if ($store_locator_bounce == 1) { ?> var marker = new google.maps.Marker({ position: point, map: MYMAP.map, animation: google.maps.Animation.BOUNCE }); <?php } else { /* dont show icon */ ?> <?php } ?> if (distance_type === "1") { var populationOptions = { strokeColor: '#FF0000', strokeOpacity: 0.25, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.15, map: MYMAP.map, center: point, radius: parseInt(radius / 0.000621371) }; } else { var populationOptions = { strokeColor: '#FF0000', strokeOpacity: 0.25, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.15, map: MYMAP.map, center: point, radius: parseInt(radius / 0.001) }; } // Add the circle for this city to the map. cityCircle = new google.maps.Circle(populationOptions); check1 = check1 + 1; } var R = 0; if (distance_type === "1") { R = 3958.7558657440545; // Radius of earth in Miles } else { R = 6378.16; // Radius of earth in kilometers } var dLat = toRad(searched_center.lat()-current_lat); var dLon = toRad(searched_center.lng()-current_lng); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(toRad(current_lat)) * Math.cos(toRad(searched_center.lat())) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; //alert("distance: "+d); if (d < radius) { show_marker_radius = true; } else { show_marker_radius = false; } } var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng)); MYMAP.bounds.extend(point); if (show_marker_radius === true) { if (wpmgza_anim === "1") { var marker = new google.maps.Marker({ position: point, map: MYMAP.map, animation: google.maps.Animation.BOUNCE }); } else if (wpmgza_anim === "2") { var marker = new google.maps.Marker({ position: point, map: MYMAP.map, animation: google.maps.Animation.DROP }); } else { var marker = new google.maps.Marker({ position: point, map: MYMAP.map }); } var d_string = ""; if (radius !== null) { if (distance_type === "1") { d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+"<?php _e("miles away", "wp-google-maps"); ?> </p>"; } else { d_string = "<p style='min-width:100px; display:block;'>"+Math.round(d,2)+"<?php _e("km away", "wp-google-maps"); ?> </p>"; } } else { d_string = ''; } var html='<p style=\'min-width:100px; display:block;\'>'+wpmgza_address+'</p>'+d_string; if (wpmgza_infoopen === "1") { infoWindow.setContent(html); infoWindow.open(MYMAP.map, marker); } <?php if ($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 } ?> } } }); } } function searchLocations(map_id) { var address = document.getElementById("addressInput").value; var geocoder = new google.maps.Geocoder(); geocoder.geocode({address: address}, function(results, status) { if (status === google.maps.GeocoderStatus.OK) { searchLocationsNear(map_id,results[0].geometry.location); } else { alert(address + ' not found'); } }); } function clearLocations() { infoWindow.close(); } function searchLocationsNear(mapid,center_searched) { clearLocations(); var distance_type = document.getElementById("wpgmza_distance_type").value; var radius = document.getElementById('radiusSelect').value; if (distance_type === "1") { if (radius === "1") { zoomie = 14; } else if (radius === "5") { zoomie = 12; } else if (radius === "10") { zoomie = 11; } else if (radius === "25") { zoomie = 9; } else if (radius === "50") { zoomie = 8; } else if (radius === "75") { zoomie = 8; } else if (radius === "100") { zoomie = 7; } else if (radius === "150") { zoomie = 7; } else if (radius === "200") { zoomie = 6; } else if (radius === "300") { zoomie = 6; } else { zoomie = 14; } } else { if (radius === "1") { zoomie = 14; } else if (radius === "5") { zoomie = 12; } else if (radius === "10") { zoomie = 11; } else if (radius === "25") { zoomie = 10; } else if (radius === "50") { zoomie = 9; } else if (radius === "75") { zoomie = 8; } else if (radius === "100") { zoomie = 8; } else if (radius === "150") { zoomie = 7; } else if (radius === "200") { zoomie = 7; } else if (radius === "300") { zoomie = 6; } else { zoomie = 14; } } MYMAP.init("#wpgmza_map", center_searched, zoomie, 3); MYMAP.placeMarkers('<?php echo wpgmaps_get_marker_url($wpgmza_current_map_id); ?> ?u='+UniqueCode,mapid,radius,center_searched,distance_type); } function toRad(Value) { /** Converts numeric degrees to radians */ return Value * Math.PI / 180; } </script> <?php } }
/** * Handle the WPGMZA shortcode * The shortcode attributes are identified and the relevant data is localized and the JS file enqueued * @param array $atts array of shortcode attributes * @return void */ function wpgmaps_tag_basic($atts) { global $wpgmza_current_map_id; global $wpgmza_version; global $short_code_active; global $wpgmza_override; extract(shortcode_atts(array('id' => '1'), $atts)); $ret_msg = ""; $wpgmza_current_map_id = $atts['id']; $res = wpgmza_get_map_data($atts['id']); if (!isset($res)) { echo __("Error: The map ID", "wp-google-maps") . " (" . $wpgmza_current_map_id . ") " . __("does not exist", "wp-google-maps"); return; } $user_api_key = get_option('wpgmza_google_maps_api_key'); if (!$user_api_key || $user_api_key == "") { $adminurl = admin_url('admin.php?page=wp-google-maps-menu-settings#tabs-4'); $link = sprintf(__("In order for your map to display, please make sure you insert your Google Maps JavaScript API key in the <a href='%s' target='_BLANK'>Maps->Settings->Advanced tab</a>.", 'wp-google-maps'), $adminurl); echo "<div class='wpgmza_error' style='background-image:url(" . plugins_url('images/map-bg.jpg', __FILE__) . "); display:block; padding:15px; border:1px solid #eee; overflow:auto;'>"; echo "<h3>" . __("WP Google Maps Error", "wp-google-maps") . "</h3>"; echo "<p style='color:#333;'><strong>" . $link . "</strong></p>"; echo "</div>"; return; } if (!function_exists('wpgmaps_admin_styles_pro')) { wp_register_style('wpgmaps-style', plugins_url('css/wpgmza_style.css', __FILE__), array(), $wpgmza_version); wp_enqueue_style('wpgmaps-style'); } if (isset($atts['zoom'])) { $zoom_override = $atts['zoom']; $wpgmza_override['zoom'] = $zoom_override; } $map_align = $res->alignment; $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); if (isset($wpgmza_settings['wpgmza_settings_marker_pull']) && $wpgmza_settings['wpgmza_settings_marker_pull'] == '0') { } else { /* only check if marker file exists if they are using the XML method */ wpgmza_check_if_marker_file_exists($wpgmza_current_map_id); } $map_width_type = stripslashes($res->map_width_type); $map_height_type = stripslashes($res->map_height_type); if (!isset($map_width_type)) { $map_width_type == "px"; } if (!isset($map_height_type)) { $map_height_type == "px"; } if ($map_width_type == "%" && intval($res->map_width) > 100) { $res->map_width = 100; } if ($map_height_type == "%" && intval($res->map_height) > 100) { $res->map_height = 100; } if (!$map_align || $map_align == "" || $map_align == "1") { $map_align = "float:left;"; } else { if ($map_align == "2") { $map_align = "margin-left:auto !important; margin-right:auto; !important; align:center;"; } else { if ($map_align == "3") { $map_align = "float:right;"; } else { if ($map_align == "4") { $map_align = ""; } } } } $map_style = "style=\"display:block; overflow:auto; width:" . $res->map_width . "" . $map_width_type . "; height:" . $res->map_height . "" . $map_height_type . "; {$map_align}\""; $map_other_settings = maybe_unserialize($res->other_settings); $sl_data = ""; if (isset($map_other_settings['store_locator_enabled']) && $map_other_settings['store_locator_enabled'] == 1) { $sl_data = wpgmaps_sl_user_output_basic($wpgmza_current_map_id); } else { $sl_data = ""; } $ret_msg .= "\n <style>\n #wpgmza_map img { max-width:none !important; }\n .wpgmza_widget { overflow: auto; }\n </style>\n \n {$sl_data} \n <div id=\"wpgmza_map\" {$map_style}>\n </div>\n "; if (isset($wpgmza_main_settings['wpgmza_custom_css']) && $wpgmza_main_settings['wpgmza_custom_css'] != "") { $ret_msg = "\n <!-- WP Google Maps Custom CSS -->\n <style type=\"text/css\">" . $wpgmza_main_settings['wpgmza_custom_css'] . "</style>\n " . $ret_msg; } $wpgmza_locale = get_locale(); $wpgmza_suffix = ".com"; /* Hebrew correction */ if ($wpgmza_locale == "he_IL") { $wpgmza_locale = "iw"; } /* Chinese integration */ if ($wpgmza_locale == "zh_CN") { $wpgmza_suffix = ".cn"; } else { $wpgmza_suffix = ".com"; } $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); /** * Only register the below scrips so that they are available on demand. */ if (isset($wpgmza_settings['wpgmza_settings_remove_api']) && $wpgmza_settings['wpgmza_settings_remove_api'] == "yes") { $wpgaps_core_dependancy = array(); } else { 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&"; } $wpgmza_api_key = get_option('wpgmza_google_maps_api_key'); if ($wpgmza_api_key) { wp_enqueue_script('wpgmza_api_call', '//maps.google' . $wpgmza_suffix . '/maps/api/js?' . $api_version_string . 'key=' . $wpgmza_api_key . '&language=' . $wpgmza_locale, array(), null); } else { wp_enqueue_script('wpgmza_api_call', '//maps.google' . $wpgmza_suffix . '/maps/api/js?' . $api_version_string . 'language=' . $wpgmza_locale, array(), null); } $wpgaps_core_dependancy = array('wpgmza_api_call'); } wp_enqueue_script('wpgmaps_core', plugins_url('/js/wpgmaps.min.js', __FILE__), $wpgaps_core_dependancy, $wpgmza_version . 'b', false); $res = array(); $res[0] = wpgmza_get_map_data($wpgmza_current_map_id); $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); if (isset($wpgmza_settings['wpgmza_api_version'])) { $api_version = $wpgmza_settings['wpgmza_api_version']; if (isset($api_version) && $api_version != "") { $api_version_string = "v={$api_version}&"; } else { $api_version_string = "v=3.exp&"; } } else { $api_version_string = "v=3.exp&"; } $map_other_settings = maybe_unserialize($res[0]->other_settings); $res[0]->other_settings = $map_other_settings; $res[0]->map_width_type = stripslashes($res[0]->map_width_type); if (isset($res[0]->other_settings['wpgmza_theme_data']) && $res[0]->other_settings['wpgmza_theme_data'] != '') { $res[0]->other_settings['wpgmza_theme_data'] = html_entity_decode(stripslashes($res[0]->other_settings['wpgmza_theme_data'])); } $polygonoptions = array(); $total_poly_array = wpgmza_b_return_polygon_id_array($wpgmza_current_map_id); if ($total_poly_array > 0) { foreach ($total_poly_array as $poly_id) { $polygonoptions[$poly_id] = wpgmza_b_return_poly_options($poly_id); $tmp_poly_array = wpgmza_b_return_polygon_array($poly_id); $poly_data_raw_array = array(); foreach ($tmp_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]; $poly_data_raw_array[] = $poly_data_raw; } $polygonoptions[$poly_id]->polydata = $poly_data_raw_array; $linecolor = $polygonoptions[$poly_id]->linecolor; $fillcolor = $polygonoptions[$poly_id]->fillcolor; $fillopacity = $polygonoptions[$poly_id]->opacity; if (!$linecolor) { $polygonoptions[$poly_id]->linecolor = "000000"; } if (!$fillcolor) { $polygonoptions[$poly_id]->fillcolor = "66FF00"; } if (!$fillopacity) { $polygonoptions[$poly_id]->opacity = "0.5"; } } } else { $polygonoptions = array(); } $polylineoptions = array(); $total_poly_array = wpgmza_b_return_polyline_id_array($wpgmza_current_map_id); if ($total_poly_array > 0) { foreach ($total_poly_array as $poly_id) { $polylineoptions[$poly_id] = wpgmza_b_return_polyline_options($poly_id); $tmp_poly_array = wpgmza_b_return_polyline_array($poly_id); $poly_data_raw_array = array(); foreach ($tmp_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]; $poly_data_raw_array[] = $poly_data_raw; } $polylineoptions[$poly_id]->polydata = $poly_data_raw_array; if (isset($polylineoptions[$poly_id]->linecolor)) { $linecolor = $polylineoptions[$poly_id]->linecolor; } else { $linecolor = false; } if (isset($polylineoptions[$poly_id]->fillcolor)) { $fillcolor = $polylineoptions[$poly_id]->fillcolor; } else { $fillcolor = false; } if (isset($polylineoptions[$poly_id]->opacity)) { $fillopacity = $polylineoptions[$poly_id]->opacity; } else { $fillopacity = false; } if (!$linecolor) { $polylineoptions[$poly_id]->linecolor = "000000"; } if (!$fillcolor) { $polylineoptions[$poly_id]->fillcolor = "66FF00"; } if (!$fillopacity) { $polylineoptions[$poly_id]->opacity = "0.5"; } } } else { $polylineoptions = array(); } if (isset($wpgmza_settings['wpgmza_settings_marker_pull']) && $wpgmza_settings['wpgmza_settings_marker_pull'] == "0") { $markers = wpgmaps_return_markers($wpgmza_current_map_id); } do_action("wpgooglemaps_basic_hook_user_js_after_core"); wp_localize_script('wpgmaps_core', 'wpgmaps_localize', $res); wp_localize_script('wpgmaps_core', 'wpgmaps_localize_polygon_settings', $polygonoptions); wp_localize_script('wpgmaps_core', 'wpgmaps_localize_polyline_settings', $polylineoptions); wp_localize_script('wpgmaps_core', 'wpgmaps_markerurl', wpgmaps_get_marker_url($wpgmza_current_map_id)); if ($wpgmza_settings['wpgmza_settings_marker_pull'] == "0") { wp_localize_script('wpgmaps_core', 'wpgmaps_localize_marker_data', $markers); } $wpgmza_settings = apply_filters("wpgmza_basic_filter_localize_settings", $wpgmza_settings); wp_localize_script('wpgmaps_core', 'wpgmaps_localize_global_settings', $wpgmza_settings); wp_localize_script('wpgmaps_core', 'wpgmaps_lang_km_away', __("km away", "wp-google-maps")); wp_localize_script('wpgmaps_core', 'wpgmaps_lang_m_away', __("miles away", "wp-google-maps")); return $ret_msg; }
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(" "); 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 } } } } } } }
<link rel="stylesheet" href="http://code.jquery.com/ui/1.8.24/themes/smoothness/jquery-ui.css" /> <link rel='stylesheet' id='wpgooglemaps-css' href='<?php echo wpgmaps_get_plugin_url(); ?> /css/wpgmza_style.css' type='text/css' media='all' /> <link rel="stylesheet" type="text/css" media="all" href="<?php echo wpgmaps_get_plugin_url(); ?> /css/data_table.css" /> <script type="text/javascript" src="<?php echo wpgmaps_get_plugin_url(); ?> /js/jquery.dataTables.js"></script> <script type="text/javascript" > if ('undefined' == typeof window.jQuery) { alert("jQuery is not installed. WP Google Maps requires jQuery in order to function properly. Please ensure you have jQuery installed.") } else { // all good.. continue... } jQuery(function() { jQuery(document).ready(function(){ wpgmzaTable = jQuery('#wpgmza_table').dataTable({ "bProcessing": true, "aaSorting": [[ 0, "desc" ]] }); function wpgmza_reinitialisetbl() { wpgmzaTable.fnClearTable( 0 ); wpgmzaTable = jQuery('#wpgmza_table').dataTable({ "bProcessing": true }); } 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) { wpgmza_InitMap(); jQuery("#wpgmza_marker_holder").html(response); wpgmza_reinitialisetbl(); //jQuery("#wpgmza_tr_"+cur_id).css("display","none"); }); }); jQuery("body").on("click", ".wpgmza_edit_btn", function() { var cur_id = jQuery(this).attr("id"); var wpgmza_edit_address = jQuery("#wpgmza_hid_marker_address_"+cur_id).val(); var wpgmza_edit_title = jQuery("#wpgmza_hid_marker_title_"+cur_id).val(); jQuery("#wpgmza_edit_id").val(cur_id); jQuery("#wpgmza_add_address").val(wpgmza_edit_address); jQuery("#wpgmza_add_title").val(wpgmza_edit_title); jQuery("#wpgmza_addmarker_div").hide(); jQuery("#wpgmza_editmarker_div").show(); }); jQuery("#wpgmza_addmarker").click(function(){ jQuery("#wpgmza_addmarker").hide(); jQuery("#wpgmza_addmarker_loading").show(); var wpgm_address = "0"; var wpgm_gps = "0"; var wpgm_map_id = "0"; if (document.getElementsByName("wpgmza_add_address").length > 0) { wpgm_address = jQuery("#wpgmza_add_address").val(); } if (document.getElementsByName("wpgmza_id").length > 0) { wpgm_map_id = jQuery("#wpgmza_id").val(); }
function wpgmaps_admin_javascript_pro() { global $wpdb; global $wpgmza_tblname_maps; $ajax_nonce = wp_create_nonce("wpgmza"); if (is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "edit_marker") { wpgmaps_admin_edit_marker_javascript(); } else { if (is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "add_poly") { wpgmaps_admin_add_poly_javascript($_GET['map_id']); } else { if (is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "edit_poly") { wpgmaps_admin_edit_poly_javascript($_GET['map_id'], $_GET['poly_id']); } else { if (is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "add_polyline") { wpgmaps_admin_add_polyline_javascript($_GET['map_id']); } else { if (is_admin() && $_GET['page'] == 'wp-google-maps-menu' && $_GET['action'] == "edit_polyline") { wpgmaps_admin_edit_polyline_javascript($_GET['map_id'], $_GET['poly_id']); } else { if (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 = stripslashes($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; 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"; } // 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 = 4; } else { if ($res->order_markers_by == 4) { $order_by = 5; } else { if ($res->order_markers_by == 5) { $order_by = 3; } else { $order_by = 0; } } } } } if ($res->order_markers_choice == 1) { $order_choice = "asc"; } else { $order_choice = "desc"; } ?> <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" href="http://code.jquery.com/ui/1.8.24/themes/smoothness/jquery-ui.css" /> <link rel="stylesheet" type="text/css" media="all" href="<?php echo wpgmaps_get_plugin_url(); ?> /css/data_table.css" /> <script type="text/javascript" src="<?php echo wpgmaps_get_plugin_url(); ?> /js/jquery.dataTables.js"></script> <script type="text/javascript" > jQuery(function() { var wpgmzaTable; 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) { wpgmza_InitMap(); jQuery("#wpgmza_marker_holder").html(response); 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("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(); var wpgmza_edit_address = jQuery("#wpgmza_hid_marker_address_"+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_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("#wpgmza_category").val(wpgmza_edit_category); jQuery("#wpgmza_infoopen").val(wpgmza_edit_infoopen); jQuery("#wpgmza_add_custom_marker").val(wpgmza_edit_icon); jQuery("#wpgmza_cmm").html("<img src='"+wpgmza_edit_icon+"' />"); jQuery("#wpgmza_addmarker_div").hide(); jQuery("#wpgmza_editmarker_div").show(); }); 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_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(); } if (document.getElementsByName("wpgmza_category").length > 0) { wpgm_category = jQuery("#wpgmza_category").val(); } 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(); } 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, pic: wpgm_pic, anim: wpgm_anim, category: wpgm_category, infoopen: wpgm_infoopen, lat: wpgm_lat, lng: wpgm_lng }; jQuery.post(ajaxurl, data, function(response) { wpgmza_InitMap(); jQuery("#wpgmza_marker_holder").html(response); 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("None"); jQuery("#wpgmza_category").val("Select"); jQuery("#wpgmza_edit_id").val(""); 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_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(); } 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(); } 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, desc: wpgm_desc, link: wpgm_link, pic: wpgm_pic, anim: wpgm_anim, category: wpgm_category, infoopen: wpgm_infoopen }; jQuery.post(ajaxurl, data, function(response) { wpgmza_InitMap(); jQuery("#wpgmza_marker_holder").html(response); 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_animation").val("None"); jQuery("#wpgmza_category").val("Select"); jQuery("#wpgmza_cmm").html(""); wpgmza_reinitialisetbl(); }); } else { alert("<?php _e("Geocode was not successful for the following reason", "wp-google-maps"); ?> : " + status); } }); }); }); }); var MYMAP = { map: null, bounds: null, mc: null } MYMAP.init = function(selector, latLng, zoom) { var myOptions = { zoom:zoom, center: latLng, scrollwheel: <?php if ($wpgmza_settings['wpgmza_settings_map_scroll'] == "yes") { echo "false"; } else { echo "true"; } ?> , zoomControl: <?php if ($wpgmza_settings['wpgmza_settings_map_zoom'] == "yes") { echo "false"; } else { echo "true"; } ?> , panControl: <?php if ($wpgmza_settings['wpgmza_settings_map_pan'] == "yes") { echo "false"; } else { echo "true"; } ?> , mapTypeControl: <?php if ($wpgmza_settings['wpgmza_settings_map_type'] == "yes") { echo "false"; } else { echo "true"; } ?> , streetViewControl: <?php if ($wpgmza_settings['wpgmza_settings_map_streetview'] == "yes") { echo "false"; } else { echo "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(); google.maps.event.addListener(MYMAP.map, 'zoom_changed', function() { zoomLevel = MYMAP.map.getZoom(); jQuery("#wpgmza_start_zoom").val(zoomLevel); }); <?php $total_poly_array = wpgmza_return_polygon_id_array($_GET['map_id']); if ($total_poly_array > 0) { foreach ($total_poly_array as $poly_id) { $polyoptions = wpgmza_return_poly_options($poly_id); $linecolor = $polyoptions->linecolor; $fillcolor = $polyoptions->fillcolor; $fillopacity = $polyoptions->opacity; if (!$linecolor) { $linecolor = "000000"; } if (!$fillcolor) { $fillcolor = "66FF00"; } if (!$fillopacity) { $fillopacity = "0.5"; } $linecolor = "#" . $linecolor; $fillcolor = "#" . $fillcolor; ?> var WPGM_PathData_<?php echo $poly_id; ?> = [ <?php $poly_array = wpgmza_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; ?> ", 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_return_polyline_id_array($_GET['map_id']); if ($total_polyline_array > 0) { foreach ($total_polyline_array as $poly_id) { $polyoptions = wpgmza_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_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 } } ?> 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 ($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 } ?> } // end of map init var infoWindow = new google.maps.InfoWindow(); <?php $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); $wpgmza_settings_infowindow_width = $wpgmza_settings['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 = []; 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_infoopen = jQuery(this).find('infoopen').text(); var wpmgza_linkd = jQuery(this).find('linkd').text(); if (wpmgza_title != "") { wpmgza_title = wpmgza_title+'<br />'; } if (wpmgza_image != "") { <?php $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); $wpgmza_image_height = $wpgmza_settings['wpgmza_settings_image_height']; $wpgmza_image_width = $wpgmza_settings['wpgmza_settings_image_width']; if (!$wpgmza_image_height || !isset($wpgmza_image_height)) { $wpgmza_image_height = "100"; } if (!$wpgmza_image_width || !isset($wpgmza_image_width)) { $wpgmza_image_width = "100"; } $wpgmza_use_timthumb = $wpgmza_settings['wpgmza_settings_use_timthumb']; if ($wpgmza_use_timthumb == "" || !isset($wpgmza_use_timthumb)) { ?> wpmgza_image = "<br /><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; margin:5px;\" />"; <?php } else { ?> wpmgza_image = "<br /><img src='"+wpmgza_image+"' class='wpgmza_map_image' style=\"float:right; margin:5px; height:<?php echo $wpgmza_image_height; ?> px; width:<?php echo $wpgmza_image_width; ?> px\" />"; <?php } ?> } else { wpmgza_image = "" } if (wpmgza_linkd != "") { <?php $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); $wpgmza_settings_infowindow_links = $wpgmza_settings['wpgmza_settings_infowindow_links']; if ($wpgmza_settings_infowindow_links == "yes") { $wpgmza_settings_infowindow_links = "target='_BLANK'"; } ?> wpmgza_linkd = "<a href='"+wpmgza_linkd+"' <?php echo $wpgmza_settings_infowindow_links; ?> title='<?php _e("More details", "wp-google-maps"); ?> '><?php _e("More details", "wp-google-maps"); ?> </a><br />"; } if (wpmgza_mapicon == "" || !wpmgza_mapicon) { if (wpgmza_def_icon != "") { wpmgza_mapicon = '<?php echo $wpgmza_default_icon; ?> '; } } 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"); $wpgmza_settings_infowindow_address = $wpgmza_settings['wpgmza_settings_infowindow_address']; if ($wpgmza_settings_infowindow_address == "yes") { ?> wpmgza_show_address = ""; <?php } ?> var html='<div id="wpgmza_markerbox">' +wpmgza_image+ '<strong>' +wpmgza_title+ '</strong>'+wpmgza_show_address+'<br /><span style="font-size:12px;">' +wpmgza_desc+ '<br />' +wpmgza_linkd+ '' +'</span></div>'; if (wpmgza_infoopen == "1") { infoWindow.setContent(html); infoWindow.open(MYMAP.map, marker); } google.maps.event.addListener(marker, 'click', function() { infoWindow.close(); infoWindow.setContent(html); infoWindow.open(MYMAP.map, marker); // MYMAP.map.setCenter(this.position); }); //MYMAP.map.fitBounds(MYMAP.bounds); } }); }); } </script> <?php } } } } } } }
function wpgmaps_user_javascript_basic() { global $short_code_active; global $wpgmza_current_map_id; wpgmaps_debugger("u_js_b_start"); if ($short_code_active) { $ajax_nonce = wp_create_nonce("wpgmza"); $res = wpgmza_get_map_data($wpgmza_current_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_map_type = $res->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 (!$wpgmza_lat || !$wpgmza_lng) { $wpgmza_lat = "51.5081290"; $wpgmza_lng = "-0.1280050"; } ?> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" > jQuery(function() { jQuery(document).ready(function(){ jQuery("#wpgmza_map").css({ height:<?php echo $wpgmza_height; ?> , width:<?php echo $wpgmza_width; ?> }); 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($wpgmza_current_map_id); ?> ?u='+UniqueCode,<?php echo $wpgmza_current_map_id; ?> ); }); }); var MYMAP = { map: null, bounds: null } MYMAP.init = function(selector, latLng, zoom) { var myOptions = { zoom:zoom, center: latLng, zoomControl: <?php if ($wpgmza_settings['wpgmza_settings_map_zoom'] == "yes") { echo "false"; } else { echo "true"; } ?> , panControl: <?php if ($wpgmza_settings['wpgmza_settings_map_pan'] == "yes") { echo "false"; } else { echo "true"; } ?> , mapTypeControl: <?php if ($wpgmza_settings['wpgmza_settings_map_type'] == "yes") { echo "false"; } else { echo "true"; } ?> , streetViewControl: <?php if ($wpgmza_settings['wpgmza_settings_map_streetview'] == "yes") { echo "false"; } else { echo "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(); google.maps.event.addListener(MYMAP.map, 'click', function() { infoWindow.close(); }); } var infoWindow = new google.maps.InfoWindow(); <?php $wpgmza_settings = get_option("WPGMZA_OTHER_SETTINGS"); $wpgmza_settings_infowindow_width = $wpgmza_settings['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; ?> }); MYMAP.placeMarkers = function(filename,map_id) { jQuery.get(filename, function(xml){ jQuery(xml).find("marker").each(function(){ var wpmgza_map_id = jQuery(this).find('map_id').text(); if (wpmgza_map_id == map_id) { var wpmgza_address = jQuery(this).find('address').text(); 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); var marker = new google.maps.Marker({ position: point, map: MYMAP.map }); var html='<strong>'+wpmgza_address+'</strong>'; google.maps.event.addListener(marker, 'click', function(evt) { infoWindow.close(); infoWindow.setContent(html); infoWindow.open(MYMAP.map, marker); //MYMAP.map.setCenter(this.position); }); } }); }); } </script> <?php } wpgmaps_debugger("u_js_b_end"); }