Fudge2

  1. Home
  2. Docs
  3. Fudge2
  4. Frequently Asked Questions
  5. How to zoom in the map when clicking on the POI?

How to zoom in the map when clicking on the POI?

1) Copy wp-content/themes/fudge-2/assets/js/jquery.map.js to wp-content/themes/fudge2-child/js/jquery.map.js

2) Login to the dashboard. Navigate appearance -> Editor menu. Select functions.php (Fudge 2 Child: Theme Functions) from the right side of the page.

Add the following code after <?php line

add_action(‘wp_print_scripts’, ‘fudge2_child_custom_js’);
function fudge2_child_custom_js(){

wp_dequeue_script(‘fudge-jquery-map’);
wp_enqueue_script( ‘fudge-child-map’, get_stylesheet_directory_uri() . ‘/js/jquery.map.js’, array( ‘jquery’ ), false, false );
}

3) Update the file.

4) Open wp-content/themes/fudge2-child/js/jquery.map.js

5) Around line number 91, you can find:

_checkPlacemerk = function ( id ) {
var place = _findPlacemark( id );
if ( place !== false ) {
if ( _window.width() >= 767 ) {
_map.panTo({
lat: place.getPosition().lat(),
lng: place.getPosition().lng() – delta / markerZoom
});
} else {
_map.panTo({
lat: place.getPosition().lat() – deltaY / markerZoom,
lng: place.getPosition().lng()
});
}
_map.setZoom( markerZoom );
place.info.open(_map, place);
}
},

6) Please change this to:

_checkPlacemerk = function ( id ) {
var place = _findPlacemark( id );
if ( place !== false ) {
if ( _window.width() >= 767 ) {
_map.panTo({
lat: place.getPosition().lat(),
lng: place.getPosition().lng() – delta / markerZoom
});
_map.setZoom( 18 );
_map.setCenter(place.getPosition());
_map.panBy(-200, 100);
} else {
_map.panTo({
lat: place.getPosition().lat() – deltaY / markerZoom,
lng: place.getPosition().lng()
});
_map.setZoom( markerZoom );
_map.setCenter(place.getPosition());
_map.panBy(100, 100);
}
// _map.setZoom( markerZoom );
place.info.open(_map, place);
}
},

7) Save the file.

Was this article helpful to you? Yes No