使用纬度和经度代码脚本生成谷歌地图 [英] Generate a google map using latitude and longitude code script

查看:134
本文介绍了使用纬度和经度代码脚本生成谷歌地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有经纬度代码。



有很多脚本,但是使用我拥有的纬度和经度代码在我的网页上显示地图的最快捷方式是什么?



这是当前代码: - 没有显示地图

 <!DOCTYPE HTML PUBLIC -  // W3C // DTD HTML 4.0 Transitional / / EN> 
< html>
< head>
< title>< / title>

< script type =text / javascriptsrc =http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js>< /脚本>
< script type =text / javascriptsrc =https://maps.googleapis.com/maps/api/js?sensor=false>< / script>

< script>
$(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
});
})
< / script>

< / head>
< body>

< div id =map>< / div>
< / body>
< / html>


解决方案

标记

 < script language = javascript src ='http://maps.google.com/maps/api/js?sensor = false' >< /脚本> 
< div id =map>< / div>

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
});
}


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 display the map on my web page using the latitude and longitude codes that I have?

This is the current code: - No map is being displayed

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title></title>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js"></script>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>

    <script>
    $(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"
         });
    }) 
    </script>

    </head>
    <body>

    <div id="map"></div>
    </body>
    </html>

解决方案

Markup

<script language=javascript src='http://maps.google.com/maps/api/js?sensor=false'></script>
<div id="map"></div>

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"
     });
} 

这篇关于使用纬度和经度代码脚本生成谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆