There are two buttons to show the results: "On the map" and "List". How to make it so that when you click on the "List" card was removed, then by clicking on "On the map" loaded?

$("body").on("click", ".search_show_map", function(){ $("#result_search").html('<div class="search_result_map" id="map_canvas" style="width:100%;height:500px"></div>'); var map; function initMap() { map = new google.maps.Map(document.getElementById('map_canvas'), { center: {lat: -34.397, lng: 150.644}, zoom: 8 }); } initMap(); }); $("body").on("click", ".search_show_list", function(){ $("#result_search").html(""); }); 

By clicking on "On the map" is loaded, after clicking on the "List" disappears, but then by clicking on "On the map" - the card is not loaded: (

  • one
    It may be better not to remove the card, but just hide it. - Dmitriy Kondratiuk
  • because it needs to be reinitialized with the function initMap () - Jean-Claude

0