Add Marker function with Google Maps API

前端 未结 5 1429
梦如初夏
梦如初夏 2020-11-29 06:45

I have the following Javascript that includes both the standard Google Maps API initialize() function and custom addMarker() function. The map will

5条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 07:15

    function initialize() {
        var location = new google.maps.LatLng(44.5403, -78.5463);
        var mapCanvas = document.getElementById('map_canvas');
        var map_options = {
          center: location,
          zoom: 15,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(map_canvas, map_options);
    
        new google.maps.Marker({
            position: location,
            map: map
        });
    }
    google.maps.event.addDomListener(window, 'load', initialize);
    

提交回复
热议问题