Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wpyog_press_scripts() {
- // Load Google Maps API. Make sure to add the callback and add custom-scripts dependency
- wp_register_script('wpyog-google-maps', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBDpN1kFL3vTBAjWQySIVsCMdrzDTRdTL0&callback=initMap', array(),
- '1.0',
- true
- );
- }
- add_action( 'wp_enqueue_scripts', 'wpyog_press_scripts' );
- add_shortcode( 'wpyog_map_locator_frontend', 'wpyog_map_locator_frontend' );
- function wpyog_map_locator_frontend(){
- global $wpdb,$content;
- ob_start();
- wp_enqueue_script('wpyog-google-maps'); ?>
- <script>
- var map;
- var markers = [];
- var infoWindow;
- var locationSelect;
- function initMap() {
- var uk_country = {lat: 51.509865, lng: -0.118092};
- map = new google.maps.Map(document.getElementById('map'), {
- center: uk_country,
- zoom: 6,
- mapTypeId: 'roadmap',
- mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
- });
- infoWindow = new google.maps.InfoWindow();
- }
- <?php
- $includeFile = WPYog_MAP_LOCATOR_DIR.'views/wpyog_map_locator_frontend.php';
- include( $includeFile );
- return ob_get_clean();
- }
- <div id="map" style="width: 100%; height: 90%;"></div>
Add Comment
Please, Sign In to add comment