地图刷新按钮单击Javascript

Map refresh on button click-Javascript

本文关键字:Javascript 单击 按钮 刷新 地图      更新时间:2023-09-26

JS:

function initialize() {
  var latLng = new google.maps.LatLng({{location_latitude}}, {{location_longitude}});
  var map = new google.maps.Map(document.getElementById('mapCanvas'), {
    zoom: 8,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });

在加载页面时正在加载映射。

除此之外,我需要它在点击按钮时刷新地图,即"<button>Refresh Map</button>"

如何在单击Refresh Map按钮时刷新地图。

$('button').on('click',initialize);