Google Map:如果单击按钮,则不会显示标记图标

时间:2018-07-31 09:21:14

标签: php laravel google-maps

当我单击按钮时,我想具有功能,标记将显示在google map中,但是首先我尝试不使用单击功能,将标记显示在不同的位置,但是当我尝试使用Jquery单击功能时,标记没有显示在该地点或位置。

问题::单击按钮后如何显示所有标记。

问题:问题是我提交后在Google地图上找不到标记。

HTML:

<button id="submit_google"  class="btn waves-effect waves-light btn-small  red darken-4  " type="submit" name="action" value="Geocode">Find Location

JS:

 $('.city').click(function(){


  var city = $(this).attr('href');

   $('#city_click').val(city);

  jQuery('#submit_google').click();

   var features = [

   {

   position: new google.maps.LatLng(53.459777, -113.406811),
   type: 'info',

   },

  {

     position: new google.maps.LatLng(53.454154, -113.408880),
     type: 'info'
  },

  ];

          // Create markers.
  features.forEach(function(feature) {
  var marker = new google.maps.Marker({
  position: feature.position,
  icon: google.maps.marker,
  map: map
  });
});





      });

1 个答案:

答案 0 :(得分:0)

可能,使用提交按钮时出现错误。它可能会尝试将您发送到新页面。尝试将event作为参数传递给回调,然后添加:event.preventDefault();

相关问题