Changeset 3128010
- Timestamp:
- 07/30/2024 09:41:19 AM (20 months ago)
- Location:
- hfd-epost-integration/trunk
- Files:
-
- 7 edited
-
class/Helper/Spot.php (modified) (1 diff)
-
css/style.css (modified) (1 diff)
-
hfd-woocommerce-epost.php (modified) (1 diff)
-
js/map.js (modified) (7 diffs)
-
js/pickup-post.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
templates/cart/footer.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
hfd-epost-integration/trunk/class/Helper/Spot.php
r3060497 r3128010 39 39 $xml = simplexml_load_string( $response, 'SimpleXMLElement', LIBXML_NOCDATA ); 40 40 $arrResponse = json_decode(wp_json_encode($xml), true); 41 41 42 42 $spots = array(); 43 43 if( isset( $arrResponse['spots']['spot_detail'] ) && !empty( $arrResponse['spots']['spot_detail'] ) ){ -
hfd-epost-integration/trunk/css/style.css
r3059826 r3128010 242 242 } 243 243 244 .autocomplete { 245 /*the container must be positioned relative:*/ 246 position: relative; 247 display: inline-block; 248 } 249 .autocomplete-items { 250 position: absolute; 251 border: 1px solid #d4d4d4; 252 border-bottom: none; 253 border-top: none; 254 z-index: 99; 255 /*position the autocomplete items to be the same width as the container:*/ 256 top: 100%; 257 left: 0; 258 right: 0; 259 } 260 .autocomplete-items div { 261 padding: 10px; 262 cursor: pointer; 263 background-color: #fff; 264 border-bottom: 1px solid #d4d4d4; 265 } 266 .autocomplete-items div:hover { 267 /*when hovering an item:*/ 268 background-color: #e9e9e9; 269 } 270 .autocomplete-active { 271 /*when navigating through the items using the arrow keys:*/ 272 background-color: DodgerBlue !important; 273 color: #ffffff; 274 } 244 275 @media only screen and (max-width: 767px){ 245 276 #legend { -
hfd-epost-integration/trunk/hfd-woocommerce-epost.php
r3097702 r3128010 5 5 Plugin URI: 6 6 Description: Add shipping method of ePost, allowing the user on the checkout, to select the pickup location point from a google map popup. Also allows to synch the order to HFD API after the order is created. 7 Version: 2. 37 Version: 2.5 8 8 Author: HFD 9 9 Author URI: https://www.hfd.co.il -
hfd-epost-integration/trunk/js/map.js
r3097702 r3128010 5 5 markers: {}, 6 6 current_spot: null, 7 8 7 init: function () { 9 8 var _this = this; … … 14 13 }); 15 14 16 var searchInput = $j('#pac-input');17 15 $j(window).trigger('resize'); 18 16 … … 21 19 22 20 drawMap: async function(){ 23 const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");24 21 const { AutocompleteService } = await google.maps.importLibrary("places"); 25 22 26 //const placeAutocomplete = new google.maps.places.PlaceAutocompleteElement(); 27 //placeAutocomplete.id = "place-autocomplete-input"; 28 29 this.map = new google.maps.Map(document.getElementById('israelpost-map'), { 23 this.map = new google.maps.Map(document.getElementById('israelpost-map'), { 30 24 center: {lat: 32.063940, lng: 34.837801}, 31 25 zoom: 12, 32 26 mapId: 'hfd19integration' 33 27 }); 34 var map = this.map; 35 var searchContainer = document.getElementById('israelpost-autocompelete'); 36 var input = (document.getElementById('pac-input')); 28 29 window.gmap = this.map; 30 31 var searchContainer = document.getElementById('israelpost-autocompelete'); 37 32 var legend = (document.getElementById('legend')); 38 33 … … 40 35 this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(legend); 41 36 this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(searchContainer); 42 43 //const searchBox = new google.maps.places.SearchBox(input);44 var options = {45 //componentRestrictions: {country: 'il'}46 bounds: map.getBounds(),47 strictBounds: true,48 types: ['matched_substrings'],49 };50 51 var searchBox = new google.maps.places.Autocomplete(input, options);52 // Bias the SearchBox results towards current map's viewport.53 map.addListener("bounds_changed", () => {54 searchBox.setBounds(map.getBounds());55 console.log( "test" );56 });57 58 /* const pac = new google.maps.places.PlaceAutocompleteElement({59 locationRestriction: map.getBounds(),60 }); */61 searchBox.addListener("place_changed", () => {62 const place = searchBox.getPlace();63 if( !place.geometry ){64 window.alert( "Autocomplete's returned place contains no geometry" );65 return;66 }67 if (place.geometry.viewport) {68 console.log( 'first' );69 map.fitBounds(place.geometry.viewport);70 } else {71 console.log( 'second' );72 map.setCenter(place.geometry.location);73 map.setZoom(17); // Why 17? Because it looks good.74 }75 /* places.forEach((place) => {76 if( !place.geometry ){77 window.alert( "Autocomplete's returned place contains no geometry" );78 return;79 }80 81 if( place.geometry.viewport ){82 map.fitBounds( place.geometry.viewport );83 } else {84 map.setCenter( place.geometry.location );85 map.setZoom(17); // Why 17? Because it looks good.86 }87 }); */88 });89 37 }, 90 38 buildContent: function( spot ){ … … 106 54 return content; 107 55 }, 108 109 56 pinMarkers: async function (spots) { 110 57 const { AdvancedMarkerElement } = await google.maps.importLibrary("marker"); 111 58 const { Map, InfoWindow } = await google.maps.importLibrary("maps"); 112 59 60 var spotList = []; 113 61 spots = spots || {}; 114 62 var _this = this, … … 126 74 var icon = IsraelPostCommon.getConfig('grnDotPath'); 127 75 } 76 77 spotList.push( spot ); 128 78 129 79 const hfdImg = document.createElement("img"); … … 152 102 anchor: marker, 153 103 }); 154 }); 104 }); 155 105 } 156 106 157 107 google.maps.event.addListenerOnce(_this.map, 'idle', function () { 158 108 google.maps.event.trigger(_this.map, 'resize'); 159 109 }); 110 111 var selectOpt = []; 112 var searchInput = ( document.getElementById( 'pac-input' ) ); 113 spotList.forEach( spot => { 114 selectOpt.push( spot.name ); 115 }); 116 117 autocomplete( document.getElementById( "pac-input" ), selectOpt ); 118 119 window.spotsLists = spotList; 120 window.map = this.map; 121 122 jQuery( document ).on( 'click', '.hfd_autocomplete_spot', function(e){ 123 console.log( "clicked" ); 124 var dataVal = jQuery( this ).find( 'input' ).val(); 125 if( dataVal != "" ){ 126 var optionVal = jQuery( "#pac-input" ).find( "option[value='"+dataVal+"']" ); 127 window.spotsLists.forEach( spot => { 128 if( spot.name == dataVal ){ 129 var icon = IsraelPostCommon.getConfig( 'redDotPath' ); 130 if( spot.type == 'חנות' ){ 131 var icon = IsraelPostCommon.getConfig( 'grnDotPath' ); 132 } 133 const hfdImg = document.createElement( "img" ); 134 hfdImg.src = icon; 135 136 //google maps marker 137 const marker = new AdvancedMarkerElement({ 138 position: new google.maps.LatLng(spot.latitude, spot.longitude), 139 map: window.map, 140 content: hfdImg, 141 zIndex: null, 142 }); 143 marker.spot = spot; 144 var info_window = new InfoWindow({ 145 content: IsraelPostMap.buildContent( marker.spot ), 146 }); 147 infow = info_window; 148 IsraelPostMap.current_spot = marker.spot; 149 info_window.open({ 150 anchor: marker, 151 }); 152 } 153 }); 154 } 155 }); 160 156 }, 161 157 -
hfd-epost-integration/trunk/js/pickup-post.js
r3060497 r3128010 62 62 this.pickerButton = $j('#israelpost-additional .spot-picker'); 63 63 this.spotInfo = $j('#israelpost-additional .spot-detail'); 64 this.pickerButton.on({65 click: function (e) {66 _this.showPickerPopup(e);67 }68 });69 64 }, 70 65 -
hfd-epost-integration/trunk/readme.txt
r3097702 r3128010 4 4 Donate link: 5 5 Requires at least: 4.0 6 Tested up to: 6. 57 Stable tag: 2. 36 Tested up to: 6.6 7 Stable tag: 2.5 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later … … 90 90 * Added option to send order items 91 91 92 = 2.5 = 93 * Improved autocomplete in google map 94 92 95 == Frequently Asked Questions == 93 96 = Why Google Maps isnt loading = -
hfd-epost-integration/trunk/templates/cart/footer.php
r3097702 r3128010 15 15 if( $layout == 'map' ): ?> 16 16 <div id="israelpost-modal" style="display: none"> 17 <div id="israelpost-autocompelete" >18 <input id="pac-input" class="controls" type="text" placeholder="<?php echo esc_html( __( 'Please enter an address', 'hfd-integration' ) ); ?>" />17 <div id="israelpost-autocompelete" class="autocomplete"> 18 <input type="text" id="pac-input" placeholder="<?php echo esc_html( __( 'Please enter an address', 'hfd-integration' ) ); ?>" /> 19 19 </div> 20 20 <div id="legend" style="height: 45px;" class="pac-inner"> … … 38 38 </script> 39 39 <?php 40 wp_enqueue_script( 'hfd-autocomplete-js', $this->getSkinUrl( 'js/jquery-hfd-autocomplete.js' ) ); 40 41 wp_enqueue_script( 'hfd-common-js', $this->getSkinUrl( 'js/common.js' ) ); 41 42 wp_enqueue_script( 'hfd-gmap-js', $this->getSkinUrl( 'js/map.js' ), array(), time() );
Note: See TracChangeset
for help on using the changeset viewer.