! function(a, o) {
document.write(`
SEARCH RESULTS
Please wait while we search stores near your location...
`);
function wff_runMap() {
var map;
var boxText;
var marker=[];
var base=[];
var myOptions;
var ib=[];
var circle=null;
var markerCluster;
var bounds;
var infowindow;
var initialLocation;
var browserSupportFlag = new Boolean();
var activeWindow;
var totalPrinted;
$=jQuery.noConflict();
$.getScript('https://maps.googleapis.com/maps/api/js?key=AIzaSyBmCyVt4LBu-SHFyETbxph3ksovyAtmGuM&libraries=places&callback=Function.prototype').done(function(){
console.log('loaded maps api');
$.getScript('https://worldfiner.com/wp-content/themes/wffQNY/js/mapScripts.js').done(function(){
console.log('loaded map scripts from wff');
// Basic options for a simple Google Map
// For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions
var mapOptions = {
// How zoomed in you want the map to start at (always required)
zoom: 11,
scrollwheel: false,
center: new google.maps.LatLng(40.6700,-73.9400)
};
// Get the HTML DOM element that will contain your map
// We are using a div with id="map" seen below in the
var mapElement = document.getElementById('wff_map');
// Create the Google Map using out element and options defined above
map = new google.maps.Map(mapElement, mapOptions);
//info icon
$('.wff_storeList .wrap').on('click','.info',function(){
tmpParent=$(this).parent();
tmpParent.find('.storeProducts').slideToggle(300);
if(tmpParent.find('.storeProducts').hasClass('loaded'))
;
else
{
tmpParent.find('.storeProducts').addClass('loaded');
$.ajax({
type:'POST',
async:true,
data:'b=1347&s='+tmpParent.attr('data-id'),
url:'https://worldfiner.com/wp-content/themes/wffQNY/productsSearch.php',
success:function(msg){
tmpParent.find('.storeProducts').html(msg);
}
});
}
});
bounds = new google.maps.LatLngBounds();
infowindow = new google.maps.InfoWindow();
map.setCenter(new google.maps.LatLng(40.8379829,-74.1851056));
//get the initial markers
$('#wff_mapSearchForm input[name="lat"]').val('');
$('#wff_mapSearchForm input[name="lng"]').val('');
$('#wff_mapSearchForm input[name="postalCode"]').val('');
// Make the search bar into a Places Autocomplete search bar and select
// which detail fields should be returned about the place that
// the user selects from the suggestions.
const autocomplete = new google.maps.places.Autocomplete(document.getElementById('searchAddress'), {
componentRestrictions: {country: 'us'},
}
);
autocomplete.setFields(
['address_components', 'geometry', 'name']
);
autocomplete.addListener('place_changed', function() {
const place = autocomplete.getPlace();
if (!place.geometry) {
// User entered the name of a Place that was not suggested and
// pressed the Enter key, or the Place Details request failed.
window.alert('Please select your address');
return;
}
center=place.geometry.location;
$('input[name=lat]').val(place.geometry.location.lat());
$('input[name=lng]').val(place.geometry.location.lng());
//delete the current markers
if(marker.length>0)
{
markerCluster.clearMarkers();
for(i=0;i0)
{
for(i=0;iSEARCH RESULTSPlease wait while we search stores near your location...");
base[0] = new google.maps.Marker({
map: map,
position: new google.maps.LatLng($('input[name=lat]').val(),$('input[name=lng]').val()),
icon: 'https://worldfiner.com/wp-content/themes/wffQNY/images/homeMarker.png'
});
// Add circle overlay and bind to marker
circle = new google.maps.Circle({
map: map,
radius: 100*1000, //100 radius circle
fillColor: '#ffffff'
});
circle.bindTo('center', base[0], 'position');
map.fitBounds(circle.getBounds());
console.log('ajax start');
$.ajax({
type:'POST',
async:true,
dataType:"json",
data:$('form[name=wff_mapSearchForm]').serialize(),
url:'https://worldfiner.com/wp-content/themes/wffQNY/mapSearch.php',
error:function(msg){ console.log('ajax error'+msg); },
success:function(msg){
console.log('Ajax response');
$('.wrap').html('SEARCH RESULTS
');
if(msg=='No results'||msg=='No Stores match'||msg=='No Products for this brand'||msg=='No Brand information')
{
$('.wrap').append('No stores found that sell Valsoia');
}
else
{
totalPrinted=0;
$.each(msg, function (index, value){
console.log(value);
$('.wff_storeList .wrap').append('\
'+(totalPrinted+1)+'. '+value.post_title+'
\
'+value.address+'
\
\
Loading '+""+' products on this store...\
\
Info
\
View map\
');
boxText=''+value.post_title+'
'+value.address+'';
marker[index] = new google.maps.Marker({
position: new google.maps.LatLng(value.lat,value.lng),
map: map,
icon: 'https://worldfiner.com/wp-content/themes/wffQNY/images/marker.png'
});
bounds.extend(marker[index].position);
myOptions = {
content: boxText
,disableAutoPan: false
,maxWidth: 0
,pixelOffset: new google.maps.Size(-16,-165)
,zIndex: null
,boxStyle: {
background: 'none'
,opacity: 1
,width: "280px"
}
,closeBoxMargin: "4px 4px 0px 0px"
,closeBoxURL: "https://worldfiner.com/wp-content/themes/wffQNY/images/closeMap.svg"
,infoBoxClearance: new google.maps.Size(1, 1)
,isHidden: false
,pane: "floatPane"
,enableEventPropagation: false
};
ib[index] = new InfoBox(myOptions);
google.maps.event.addListener(marker[index], "click", function (e) {
if(activeWindow != null)
activeWindow.close();
ib[index].open(map, this);
activeWindow = ib[index];
});
totalPrinted++;
});
if(totalPrinted==0)
{
$('.wff_storeList .wrap').append('No stores found near your location');
}
map.fitBounds(bounds);
markerCluster = new MarkerClusterer(map, marker,{ignoreHidden: true});
}
}
});
console.log('after ajax');
});
if (navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) {
setTimeout(() => {
let pacContainer = document.getElementsByClassName('pac-container')[0];
pacContainer.addEventListener('touchend', function (e) {
e.stopImmediatePropagation();
});
}, 500);
}
//load first set of results
$.ajax({
type:'POST',
async:true,
dataType:"json",
data:$('form[name=wff_mapSearchForm]').serialize(),
url:'https://worldfiner.com/wp-content/themes/wffQNY/mapSearch.php',
success:function(msg){
$('.wrap').html('SEARCH RESULTS
');
if(msg=='No results'||msg=='No Stores match'||msg=='No Products for this brand'||msg=='No Brand information')
{
$('.wrap').append('No stores found that sell Valsoia');
}
else
{
totalPrinted=0;
$.each(msg, function (index, value){
console.log(value);
$('.wff_storeList .wrap').append('\
'+(totalPrinted+1)+'. '+value.post_title+'
\
'+value.address+'
\
\
Loading '+""+' products on this store...\
\
Info
\
View map\
');
boxText=''+value.post_title+'
'+value.address+'';
marker[index] = new google.maps.Marker({
position: new google.maps.LatLng(value.lat,value.lng),
map: map,
icon: 'https://worldfiner.com/wp-content/themes/wffQNY/images/marker.png'
});
bounds.extend(marker[index].position);
myOptions = {
content: boxText
,disableAutoPan: false
,maxWidth: 0
,pixelOffset: new google.maps.Size(-16,-165)
,zIndex: null
,boxStyle: {
background: 'none'
,opacity: 1
,width: "280px"
}
,closeBoxMargin: "4px 4px 0px 0px"
,closeBoxURL: "https://worldfiner.com/wp-content/themes/wffQNY/images/closeMap.svg"
,infoBoxClearance: new google.maps.Size(1, 1)
,isHidden: false
,pane: "floatPane"
,enableEventPropagation: false
};
ib[index] = new InfoBox(myOptions);
google.maps.event.addListener(marker[index], "click", function (e) {
if(activeWindow != null)
activeWindow.close();
ib[index].open(map, this);
activeWindow = ib[index];
});
totalPrinted++;
});
if(totalPrinted==0)
{
$('.wff_storeList .wrap').append('No stores found near your location');
}
map.fitBounds(bounds);
markerCluster = new MarkerClusterer(map, marker,{ignoreHidden: true});
}
}
});
});
});
}
if(typeof jQuery=='undefined') {
var headTag = document.getElementsByTagName("head")[0];
var jqTag = document.createElement('script');
jqTag.type = 'text/javascript';
jqTag.src = 'https://worldfiner.com/wp-includes/js/jquery/jquery.min.js?ver=3.7.1';
jqTag.onload = wff_runMap;
headTag.appendChild(jqTag);
} else {
wff_runMap();
}
}(window, document);