Changeset 1586515
- Timestamp:
- 02/01/2017 01:34:24 PM (9 years ago)
- Location:
- scale-lite-tools/trunk
- Files:
-
- 4 edited
-
assets/js/admin.sl-maps.js (modified) (1 diff)
-
assets/js/frontend.sl-google-maps.js (modified) (1 diff)
-
inc/sl-google-maps/class-slt-gmap-meta-fields.php (modified) (2 diffs)
-
inc/sl-google-maps/render-cpt.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
scale-lite-tools/trunk/assets/js/admin.sl-maps.js
r1577799 r1586515 1 console.log('it works'); 1 function slt_gmaps_init() { 2 var sl_preview_map = function() { 3 var geocoder = new google.maps.Geocoder(); 4 // create map element 5 var mapEl = document.getElementById("preview_map_container"); 6 var map = new google.maps.Map(mapEl, { 7 zoom: 12, 8 scrollwheel: false 9 }); 10 function mapCreate(myLocation) { 11 var marker = new google.maps.Marker({ 12 position: myLocation, 13 map: map 14 }); 15 } 16 function codeAddress(callback) { 17 var address = document.getElementById('center-map-location').value; 18 (function(){ 19 geocoder.geocode( { 'address': address}, function(results, status) { 20 if (status == 'OK') { 21 map.setCenter(results[0].geometry.location); 22 var marker = new google.maps.Marker({ 23 map: map, 24 position: results[0].geometry.location 25 }); 26 callback(results[0].geometry.location,map); 27 } else { 28 alert('Geocode was not successful for the following reason: ' + status); 29 } 30 }); 31 })(); 32 } 33 codeAddress(function(myLocation) { mapCreate(myLocation, map);}); 34 }; 35 sl_preview_map(); 36 jQuery('#slt-preview').on('click', function() { 37 sl_preview_map(); 38 }); 39 } -
scale-lite-tools/trunk/assets/js/frontend.sl-google-maps.js
r1586045 r1586515 1 1 // google maps render frontend map 2 var sl _google_maps_frontend= function() {2 var slt_gmaps_init = function() { 3 3 "use strict"; 4 4 -
scale-lite-tools/trunk/inc/sl-google-maps/class-slt-gmap-meta-fields.php
r1586471 r1586515 103 103 */ 104 104 public function add_meta_box_callback( $post ) { 105 echo '<div class="preview_map_container"></div>';105 echo '<div id="preview_map_container" class="preview_map_container"></div>'; 106 106 wp_nonce_field( 'slt_gmap_options_data', 'slt_gmap_options_nonce' ); 107 107 $this->generate_fields( $post ); … … 137 137 switch ( $field['id'] ) { 138 138 case 'center-map-location': 139 if(empty($db_value)) { 140 $db_value = '350 5th Ave, New York, NY 10118, USA'; 141 } 139 142 ($field['placeholder']) ? $field['placeholder']:''; 140 143 $input = sprintf( 141 144 '<div class="slt-map-address-container"> 142 145 <div class="slt-map-address"> 143 <textarea placeholder="%s" class="large-text" id="%s" name="%s" rows="4">%s</textarea><p class="description">Paste here anaddress, then click preview map. If you only have one marker, map will be centered there. If you have multiple markers double click on preview map to update coordinates where your map will be centered.</p>146 <textarea placeholder="%s" class="large-text" id="%s" name="%s" rows="4">%s</textarea><p class="description">Paste here your address, then click preview map. If you only have one marker, map will be centered there. If you have multiple markers double click on preview map to update coordinates where your map will be centered.</p> 144 147 </div> 145 148 <input name="slt-preview" type="button" class="button button-primary button-large" id="slt-preview" value="Preview map"> -
scale-lite-tools/trunk/inc/sl-google-maps/render-cpt.php
r1586447 r1586515 164 164 add_action('wp_enqueue_scripts', 'scale_lite_load_gmaps_v3', 50 ); 165 165 166 // Register Google maps JS v3 fro admin 167 function scale_lite_admin_load_gmaps_v3() { 168 wp_enqueue_script( 169 'scale-lite-admin-google-maps-js', 170 "https://maps.googleapis.com/maps/api/js", 171 array(), 172 '', 173 true 174 ); 175 } 176 add_action('admin_enqueue_scripts', 'scale_lite_admin_load_gmaps_v3', 50 ); 177 166 178 // add async and defer attributs to google maps script google maps JS 167 179 add_filter('clean_url','unclean_url',10,3); … … 171 183 if (false !== strpos($original_url, 'maps.googleapis.com/maps/api/js')){ 172 184 remove_filter('clean_url','unclean_url',10,3); 173 return wp_specialchars_decode($good_protocol_url).'?key='.$google_maps_api_key_0."&callback=slt_gmaps_ frontend' async='async' defer='defer";185 return wp_specialchars_decode($good_protocol_url).'?key='.$google_maps_api_key_0."&callback=slt_gmaps_init' async='async' defer='defer"; 174 186 } 175 187 return $good_protocol_url;
Note: See TracChangeset
for help on using the changeset viewer.