Guest User

Untitled

a guest
Jan 22nd, 2018
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. function wpyog_press_scripts() {
  2. // Load Google Maps API. Make sure to add the callback and add custom-scripts dependency
  3. wp_register_script('wpyog-google-maps', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyBDpN1kFL3vTBAjWQySIVsCMdrzDTRdTL0&callback=initMap', array(),
  4. '1.0',
  5. true
  6. );
  7. }
  8. add_action( 'wp_enqueue_scripts', 'wpyog_press_scripts' );
  9.  
  10. add_shortcode( 'wpyog_map_locator_frontend', 'wpyog_map_locator_frontend' );
  11. function wpyog_map_locator_frontend(){
  12. global $wpdb,$content;
  13. ob_start();
  14. wp_enqueue_script('wpyog-google-maps'); ?>
  15. <script>
  16. var map;
  17. var markers = [];
  18. var infoWindow;
  19. var locationSelect;
  20.  
  21. function initMap() {
  22. var uk_country = {lat: 51.509865, lng: -0.118092};
  23. map = new google.maps.Map(document.getElementById('map'), {
  24. center: uk_country,
  25. zoom: 6,
  26. mapTypeId: 'roadmap',
  27. mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU}
  28. });
  29. infoWindow = new google.maps.InfoWindow();
  30. }
  31.  
  32. <?php
  33. $includeFile = WPYog_MAP_LOCATOR_DIR.'views/wpyog_map_locator_frontend.php';
  34. include( $includeFile );
  35. return ob_get_clean();
  36. }
  37.  
  38. <div id="map" style="width: 100%; height: 90%;"></div>
Add Comment
Please, Sign In to add comment