PageSourceSearch

https://writersofkern.com/wp-content/plugins/business-profile/assets/js/map.js?ver=2.3.21

js writersofkern.com collected 2026-09-25 02:05:23 UTC 3,923 bytes, 113 lines download raw bytes

1/* global google */
2/**
3 * Front-end JavaScript for Business Profile maps
4 *
5 * @copyright Copyright (c) 2016, Theme of the Crop
6 * @license   GPL-2.0+
7 * @since     0.0.1
8 */
9
10var bpfwp_map = bpfwp_map || {};
11
12/**
13 * Set up a map using the Google Maps API and data attributes added to `.bp-map`
14 * elements on a given page.
15 *
16 * @uses  Google Maps API (https://developers.google.com/maps/web/)
17 * @since 1.1.0
18 */
19function bpInitializeMap() {
20	'use strict';
21
22	bpfwp_map.maps = [];
23	bpfwp_map.info_windows = [];
24
25	jQuery( '.bp-map' ).each( function() {
26		var id = jQuery( this ).attr( 'id' );
27		var data = jQuery( this ).data();
28
29		data.addressURI = encodeURIComponent( data.address.replace( /(<([^>]+)>)/ig, ', ' ) );
30
31		// Google Maps API v3
32		if ( 'undefined' !== typeof data.lat ) {
33			data.addressURI              = encodeURIComponent( data.address.replace( /(<([^>]+)>)/ig, ', ' ) );
34			bpfwp_map.map_options        = bpfwp_map.map_options || {};
35			bpfwp_map.map_options.center = new google.maps.LatLng( data.lat, data.lon );
36			if ( typeof bpfwp_map.map_options.zoom === 'undefined' ) {
37				bpfwp_map.map_options.zoom = bpfwp_map.map_options.zoom || 15;
38			}
39			bpfwp_map.maps[ id ] = new google.maps.Map( document.getElementById( id ), bpfwp_map.map_options );
40
41			var content = '<div class="bp-map-info-window">' + '<p><strong>' + data.name + '</strong></p>' + '<p>' + data.address.replace( /(?:\r\n|\r|\n)/g, '<br>' ) + '</p>';
42
43			if ( 'undefined' !== typeof data.phone ) {
44				content += '<p>' + data.phone + '</p>';
45			}
46
47			content += '<p><a target="_blank" href="//maps.google.com/maps?saddr=current+location&daddr=' + data.addressURI + '">' + bpfwp_map.strings.getDirections + '</a></p>' + '</div>';
48
49			bpfwp_map.info_windows[ id ] = new google.maps.InfoWindow({
50				position: bpfwp_map.map_options.center,
51				content: content
52			});
53			bpfwp_map.info_windows[ id ].open( bpfwp_map.maps[ id ] );
54
55			// Trigger an intiailized event on this dom element for third-party code
56			jQuery( this ).trigger( 'bpfwp.map_initialized', [ id, bpfwp_map.maps[id], bpfwp_map.info_windows[id] ] );
57
58		// Google Maps iframe embed (fallback if no lat/lon data available)
59		} else if ( '' !== data.address ) {
60			var bpMapIframe = document.createElement( 'iframe' );
61
62			bpMapIframe.frameBorder = 0;
63			bpMapIframe.style.width = '100%';
64			bpMapIframe.style.height = '100%';
65
66			if ( '' !== data.name ) {
67				data.address = data.name + ',' + data.address;
68			}
69
70			bpMapIframe.src = '//maps.google.com/maps?output=embed&q=' + encodeURIComponent( data.address );
71			bpMapIframe.src = '//maps.google.com/maps?output=embed&q=' + data.addressURI;
72
73			jQuery( this ).html( bpMapIframe );
74
75			// Trigger an intiailized event on this dom element for third-party code
76			jQuery( this ).trigger( 'bpfwp.map_initialized_in_iframe', [ jQuery( this ) ] );
77		}
78	});
79}
80
81/**
82 * Backwards-compatable alias function.
83 *
84 * @since 1.1.0
85 */
86function bp_initialize_map() {
87	bpInitializeMap();
88}
89
90jQuery( document ).ready( function() {
91	'use strict';
92
93	// Allow developers to override the maps api loading and initializing.
94	if ( ! bpfwp_map.autoload_google_maps ) {
95		return;
96	}
97	// Load Google Maps API and initialize maps.
98	if ( 'undefined' === typeof google || 'undefined' === typeof google.maps ) {
99		var bpMapScript = document.createElement( 'script' );
100		bpMapScript.type = 'text/javascript';
101		bpMapScript.src = '//maps.googleapis.com/maps/api/js?v=3.exp&callback=bp_initialize_map&loading=async';
102
103		if ( 'undefined' !== typeof bpfwp_map.google_maps_api_key ) {
104			bpMapScript.src += '&key=' + bpfwp_map.google_maps_api_key;
105		}
106
107		document.body.appendChild( bpMapScript );
108	} else {
109		// If the API is already loaded (eg - by a third-party theme or plugin),
110		// just initialize the map.
111		bp_initialize_map();
112	}
113});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.