OwlCyberSecurity - MANAGER
Edit File: google-map.php
<?php /** * Google Map */ add_shortcode( 'pearl_google_map', 'pearl_google_map' ); function pearl_google_map( $atts ) { // Params extraction extract( shortcode_atts( array( 'lat' => '', 'lng' => '', 'zoom' => '', 'direction' => '', ), $atts ) ); $map_lat = $lat; $map_lng = $lng; $map_zoom = $zoom; $map_direction = $direction; $unique_map_id = abs( $lat ); $unique_map_id = str_replace( '.', '', $unique_map_id ); ob_start(); ?> <div class="google-map-wrapper our-location"> <div id="google-map-<?php echo esc_attr( $unique_map_id ); ?>" class="google-map map"></div> <?php if ( ! empty( $map_direction ) ) { ?> <div class="get-directions"> <form action="https://maps.google.com/maps" method="get" target="_blank"> <input type="text" name="saddr" placeholder="<?php esc_html_e( 'Enter Your Address', 'pearl-medicalguide' ) ?>"/> <input type="hidden" name="daddr" value="<?php echo sanitize_text_field( $map_direction ); ?>"/> <input type="submit" class="direction-btn" value=""> </form> </div> <?php } ?> </div> <script> function initializeContactMap() { var officeLocation = new google.maps.LatLng( <?php echo esc_html( $map_lat ); ?> , <?php echo esc_html( $map_lng ); ?>); var contactMapOptions = { zoom: <?php echo esc_html( $map_zoom ); ?>, center: officeLocation, mapTypeId: google.maps.MapTypeId.ROADMAP, scrollwheel: false }; var contactMap = new google.maps.Map(document.getElementById('google-map-<?php echo esc_attr( $unique_map_id ); ?>'), contactMapOptions); var contactMarker = new google.maps.Marker({ position: officeLocation, map: contactMap }); } window.onload = initializeContactMap(); </script> <?php return ob_get_clean(); } /** * Google Map */ vc_map( array( 'name' => esc_html__( 'Google Map', 'pearl-medical-framework' ), 'base' => 'pearl_google_map', 'class' => '', "category" => esc_html__( "MedicalGuide Theme", 'pearl-medical-framework' ), 'params' => array( array( 'type' => 'textfield', 'class' => '', 'heading' => esc_html__( 'Google Map Latitude', 'pearl-medical-framework' ), 'description' => sprintf( esc_html__( 'You can use %s OR %s to get Latitude and longitude of your desired location.', 'pearl-medical-framework' ), '<a href="https://getlatlong.net" target="_blank">https://getlatlong.net</a>', '<a href="https://www.latlong.net" target="_blank">https://www.latlong.net</a>' ), "admin_label" => true, 'param_name' => 'lat', ), array( 'type' => 'textfield', 'class' => '', 'heading' => esc_html__( 'Google Map Longitude', 'pearl-medical-framework' ), "admin_label" => true, 'param_name' => 'lng', ), array( 'type' => 'textfield', 'class' => '', 'heading' => esc_html__( 'Google Map Zoom Level', 'pearl-medical-framework' ), "admin_label" => true, 'param_name' => 'zoom', ), array( 'type' => 'textfield', 'class' => '', 'heading' => esc_html__( 'Map Direction Address', 'pearl-medical-framework' ), "admin_label" => true, 'param_name' => 'direction', ) ) ) );