[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

bw_googlemap_v3() – Display a Google Map using Google Maps JavaScript API V3

Description

Display a Google Map using Google Maps JavaScript API V3

Display a Google Map

  • centred around the lat and long specified in oik options
  • zoomed to level 12 – which is good for local viewing
  • with a red marker centred at the lat,long
  • and showing the postcode as a tool tip
  • and an info window showing the title and postcode
For programming details see http://code.google.com/apis/maps/documentation/javascript/basics.html#Welcome Restrictions of this implementation
  1. Does not detect the user's location -> sensor=false
  2. Does not detect IPhone or Android devices
  3. Does not perform language localization
  4. Region defaults to GB
  5. Does not add any additional libraries. not geometry, adsense nor panoramio
  6. Does not support loading the API over HTTPS
  7. Loads synchronously – rather than Asynchronously
  8. Does not specify the version. v=3 being the default
If this doesn't work don't forget to set: #bw_map_canvas { height: 100% } in oik.css or your custom CSS file Note: the default height is 100%
  1. Oct 2014: Quick and Dirty fix to support the display of multiple Google maps on a page.
  2. Each time the routine is invoked it increments the $map variable. This is used to create multiple initialize functions. At the end of the initialize function, if the map is greater than one then it invokes the previous initialize function. So initialise1() will call initialize0() This gets over the problem of only the last initialize function being called by window.onload=initialisen;

    Usage

    bw_googlemap_v3( $title, $lat, $lng, $postcode, $width, $height, $markers, $zoom );

    Parameters

    $title
    ( string ) required – part of the infowindow
    $lat
    ( number ) required – latitude
    $lng
    ( number ) required – longitude
    $postcode
    ( string ) required – part of the infowindow
    $width
    ( string ) required – width in pixels or percentage
    $height
    ( string ) required – height in pixels
    $markers
    ( string ) optional – display multiple markers – for each alt number chosen.
    $zoom
    ( mixed ) optional default: 12 –

    Returns

    void

    Source

    File name: oik/shortcodes/oik-googlemap.php
    Lines:
    1 to 48 of 48
    function bw_googlemap_v3(  $title, $lat, $lng, $postcode, $width, $height, $markers=null, $zoom=12 ) {
      bw_trace2();
      $map = bw_gmap_map( false );
      $latlng = bw_gmap_latlng( $lat, $lng ); 
      
      if ( !$map ) {
        $src = set_url_scheme( "http://maps.googleapis.com/maps/api/js?&region=GB" );
        bw_echo( '<script type="text/javascript" src="' . $src );
        bw_echo( bw_gmap_api_key() );
        bw_echo( '"></script>' );
      }
      bw_echo( '<script type="text/javascript">' );
      bw_echo( 'function initialize' . $map . '() {' );
      bw_echo( 'var latlng = new google.maps.LatLng('. $latlng .');' );
      
      // Choose from ROADMAP, SATELLITE, HYBRID, TERRAIN 
      bw_echo( "var myOptions = { zoom: $zoom, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP };" );
      bw_echo( 'var map = new google.maps.Map(document.getElementById("bw_map_canvas' . $map . '"), myOptions); ' );
      
      if ( $postcode ) {
        bw_gmap_marker( $postcode );
        bw_gmap_infowindow( $title, $postcode );
      }
      if ( $markers ) {
        bw_gmap_markers( $markers );
      }
      
      if ( $map ) {
        $previous = $map - 1;
        bw_echo( 'initialize' . $previous. '();' );
      }
      bw_echo( '}' );
      //bw_echo( 'window.onload=initialize' . $map . ';');
      bw_echo( "window.addEventListener( 'load', initialize$map ); ");
      bw_echo( '</script>' );
      
      
      // Here we set the min-height so that the Google Map should at least be visible 
      
      if ( $height ) {
        $hv = ' height:'. $height; 
      } else {
        $hv = '';  
      }  
      bw_echo( '<div class="bw_map_canvas" id="bw_map_canvas' . $map . '" style="min-height: 200px; width:' . $width. ';' .$hv .';"></div>');
      bw_gmap_map();
    
    }
     
     View on GitHub View on Trac

    Called by

    1 to 1 of 1
    • bw_show_googlemap() – Implements [bw_show_googlemap] shortcode to display a Google Map

    Invoked by

      Calls

      1 to 8 of 8
      • bw_echo() – bw API partial equivalent of PHP’s output buffering
      • bw_gmap_api_key() – Return the Google Map API key
      • bw_gmap_infowindow() –
      • bw_gmap_latlng() – Return latlng combination
      • bw_gmap_map() – Returns the map index
      • bw_gmap_marker() – Set the Google map marker
      • bw_gmap_markers() – Insert multiple markers
      • bw_trace2() – Trace $value to the trace log file if tracing is active

      Call hooks

      Function name: bw_googlemap_v3
      Plugin ref: oik – oik information kit
      Version: 4.15.3
      Sourcefile: shortcodes/oik-googlemap.php
      File ref: shortcodes/oik-googlemap.php
      Deprecated?: No
      API Letters: B,G,V

    Published: February 2, 2018 | Last updated: February 2, 2018

    Information

    Function name: bw_googlemap_v3
    Plugin ref: oik – oik information kit
    Version: 4.15.3
    Sourcefile: shortcodes/oik-googlemap.php
    File ref: shortcodes/oik-googlemap.php
    Deprecated?: No
    API Letters: B,G,V

    Recent plugin updates

    oik-weight-zone-shipping v0.2.13 oik-weight-zone-shipping v0.2.13 has been tested with WooCommerce 10.1.2 and WordPress 6.8.2 ...
    SB Children Block v1.3.0 Upgrade to SB Children Block v1.3.0 for support for PHP 8.3 and PHP 8.4  ...
    oik v4.15.3 Update to oik v4.15.3 for a couple of security fixes. Tested with WordPress 6.8.2 ...
    oik-privacy-policy v1.4.9 Update to oik-privacy-policy v1.4.9 for a security fix. Tested with WordPress 6.8.2 and PHP 8.3 and PHP 8.4 ...
    oik-nivo-slider v1.17.0 oik-nivo-slider v1.17.0 introduces the Nivo slider block - oik-nivo-slider/nivo. ...

    Plugins

    • All Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins

    Themes

    • FREE themes
    • Bespoke themes
    • Premium themes

    Blocks

    • All Blocks
    • Block examples
    • About Blocks

    Shortcodes

    • All Shortcodes
    • Shortcode examples
    • About Shortcodes

    Reference

    • About APIs
    • All APIs
    • All Classes
    • All Files
    • All Hooks

    Support

    • Contact
    • Cookies policy
    • Get API key
    • Privacy
    • Request support
    • Sitemap
    • Stay informed
    • Terms and Conditions
    oik-plugins
    Email: herb@bobbingwide.com

    Weight shipping plugins

    Find out which cart weight shipping plugin you need for your WooCommerce site.
    Which cart weight based plugin do I need?

    Site:  www.oik-plugins.com
    © Copyright oik-plugins 2011-2025. All rights reserved.


    Website designed and developed by Herb Miller of Bobbing Wide
    Proudly powered by WordPress and oik-plugins

    WordPress version: 6.8.3

    Gutenberg version: 21.7.0

    PHP version: 8.2.29