Generate a google map using latitude and longitude code script

前端 未结 2 1841
傲寒
傲寒 2021-01-06 14:26

I need to generate a google map with a marker.

I have the latitude and longitude code.

There\'s lots of scripts around but what is the quickest way to displa

2条回答
  •  自闭症患者
    2021-01-06 14:50

    Markup

    
    

    Javascript

    function initialize(){
         var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
         var myOptions = {
             zoom: 4,
             center: myLatlng,
             mapTypeId: google.maps.MapTypeId.ROADMAP
             }
          map = new google.maps.Map(document.getElementById("map"), myOptions);
          var marker = new google.maps.Marker({
              position: myLatlng, 
              map: map,
          title:"Fast marker"
         });
    } 
    
    google.maps.event.addDomListener(window,'load', initialize);
    

    Jquery

    $(document).ready(function (){
         var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
         var myOptions = {
             zoom: 4,
             center: myLatlng,
             mapTypeId: google.maps.MapTypeId.ROADMAP
             }
          map = new google.maps.Map($('#map'), myOptions);
          var marker = new google.maps.Marker({
              position: myLatlng, 
              map: map,
          title:"Fast marker"
         });
    } 
    

提交回复
热议问题