Google Places Autocomplete not working after installing MapPress
Problem:
- Google Field Autocomplete works properly after completing points 1) and 2)
- Field Autocomplete does not work anymore after including a Google map after completing point 3)
Question:
Could somebody help determine what is causing Autocomplete to stop working after completing point 3) ?
----------------------------------------------------------------------
1) Edited file:
wp-content/themes/classipress-child/includes/search.php
Added code:
<script type="text/javascript">
var options = {
types: ['(cities)'],
componentRestrictions: {country: "ch"}
};
var input = document.getElementById('cp_city_zipcode');
var autocomplete = new google.maps.places.Autocomplete(input, options);
</script>
----------------------------------------------------------------------
2) Edited file: /
wp-content/themes/classipress-child/functions.php
Added code:
function include_google_places_api() {
//register google maps api if not already registered
if ( !wp_script_is( 'google-maps', 'registered' ) ) {
wp_register_script( 'google-maps', ( is_ssl() ? 'https' : 'http' ) . '://maps.googleapis.com/maps/api/
js?libraries=places&sensor=false', array( 'jquery' ), false );
}
//enqueue google maps api if not already enqueued
if ( !wp_script_is( 'google-maps', 'enqueued' ) ) {
wp_enqueue_script( 'google-maps' );
}
}
add_action( 'wp_enqueue_scripts', 'include_google_places_api' );
----------------------------------------------------------------------
3) Installed MapPress plugin and Added Map:
Updated file: /
wp-content/themes/classipress-child/header.php
Added lines:
<div class="header_map">
<center>
<?php
if(is_search()) {
$arg = array('w'=>'100%','h'=>'400px',); //w=width & h=height
do_action('wpw_listing_n_search_gmap',$arg);
}
?>
</center>
</div><!-- /header_map -->