Google Map 谷歌地图

痞子三分冷 提交于 2019-12-16 14:41:27
    <script> 
        var map;
        function initMap() {            
            var position = new google.maps.LatLng(1.539187, 103.647115),
                                
            map = new google.maps.Map(document.getElementById('map'), {
                center: position,
                zoom: 15, 
                styles: [去网站弄]                
            });
         
            var marker = new google.maps.Marker({
                position: position,
                map: map,
                animation: google.maps.Animation.DROP, // BOUNCE, DROP, lo, no              
                icon: 'http://www.zoominn.com.my/i/ModuleMap_icon.png'                 
            });
            marker.addListener('click', function () {
                var ttc = document.getElementById('mapContent').cloneNode(true);
                var infoWindow = new google.maps.InfoWindow;
                infoWindow.setPosition(position);
                infoWindow.setContent(ttc);  //can put element but won't auto clone 哦
                infoWindow.open(map);                    
            });          
        }

        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.async = true;
        script.defer = true;
        script.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyDzbTtAijGTrGdYxbU3FGuxnwwO3Vkmixg&callback=initMap'
        document.body.appendChild(script);

    </script>
    @*<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDzbTtAijGTrGdYxbU3FGuxnwwO3Vkmixg&callback=initMap" async defer></script>*@

refer : 

https://mapstyle.withgoogle.com/    (弄 style 的)

https://developers.google.com/maps/ (官网)

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!