0

我在我的网站上添加了一个带有一些自定义标记的 Google Maps JS API。一切都很好,但是当我第一次加载页面时,页面会向下滚动到地图,但我希望它保持在顶部。

我已经完成了我的研究,但我还没有看到其他人有这个问题。

这是页面的代码和链接。

http://clusier-new.copemanweb.ca/index.php/en/a-propos/contact.html

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"></script>
<script type="text/javascript">// <![CDATA[
        var map;
        var map2;
        var MY_MAPTYPE_ID = 'custom_style';

        function initialize() {
          var featureOpts = [
            {
              stylers: [
                { "saturation": -100 },
              ]
            }
          ];
          var styledMapOptions = {
            name: 'Clusier Style'
          };
          var image = 'http://127.0.0.1/clusier-new/media/wysiwyg/marker.png';

          var McGill = new google.maps.LatLng(45.500677,-73.561092);
          var mapOptions = {
            zoom: 16,
            center: McGill,
            mapTypeControlOptions: {
              mapTypeIds: [google.maps.MapTypeId.ROADMAP, MY_MAPTYPE_ID]
            },
            mapTypeId: MY_MAPTYPE_ID
          };
          map = new google.maps.Map(document.getElementById('McGill'),
              mapOptions);
          var myLatLng = new google.maps.LatLng(45.500417,-73.558087);
          var beachMarker = new google.maps.Marker({
              position: myLatLng,
              map: map,
              icon: image
          });
          var customMapType = new google.maps.StyledMapType(featureOpts, styledMapOptions);
          map.mapTypes.set(MY_MAPTYPE_ID, customMapType);

          var Stanley = new google.maps.LatLng(45.500700,-73.578764);
          var mapOptions = {
            zoom: 16,
            center: Stanley,
            mapTypeControlOptions: {
              mapTypeIds: [google.maps.MapTypeId.ROADMAP, MY_MAPTYPE_ID]
            },
            mapTypeId: MY_MAPTYPE_ID
          };
          map2 = new google.maps.Map(document.getElementById('Stanley'),
              mapOptions);
          var myLatLng = new google.maps.LatLng(45.500455,-73.575877);
          var beachMarker = new google.maps.Marker({
              position: myLatLng,
              map: map2,
              icon: image
          });         
          map2.mapTypes.set(MY_MAPTYPE_ID, customMapType);
        }
        google.maps.event.addDomListener(window, 'load', initialize);
// ]]></script>
<div id="visit-us">
<div><img src="{{media url="wysiwyg/contact-us-mcgill.jpg"}}" alt="Visit Us McGill" />
<p><span class="DINMedium">Boutique McGill</span><br />432 Rue McGill<br /> Montr&eacute;al, QC<br />H2Y 2G1<br /><br /> <span class="DINMedium">514-842-1717</span></p>
<div id="McGill">&nbsp;</div>
</div>
<div><img src="{{media url="wysiwyg/contact-us-stanley.jpg"}}" alt="Visit Us Stanley" />
<p><span class="DINMedium">Boutique Stanley</span><br />2041 Rue Stanley<br /> Montr&eacute;al, QC<br />H3A 1R7<br /><br /> <span class="DINMedium">514-844-3988</span></p>
<div id="Stanley">&nbsp;</div>
</div>

谢谢你的帮助,

应对99

4

1 回答 1

1

这不是 Maps-API 的问题,正如 Andy 所说,它与 Magento 有关。页面没有滚动到地图,您的联系表格将集中在:

var contactForm = new VarienForm('contactForm',true);

将第二个参数设置为 false(当它的true表单将被聚焦时)。

于 2013-10-08T18:42:30.650 回答