[Google Map] 开发正常例子

视频材料
案例代码

案例一:your_first_map

<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map"></div>
<style type="text/css">
  html, body {
    height: 100%;
    margin: 0;
  }
  #map{
    height: 100%;
    margin: 0;
  }
</style>

<script>
    var mapOptions = {
        center: new google.maps.LatLng(37.7831,-122.4039),
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    new google.maps.Map(document.getElementById('map'), mapOptions);
</script>
your_first_map

案例二:markers

<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map"></div>
<style type="text/css">
    html, body, #map {
      height: 100%;
      margin: 0;
    }
</style>
<script>
    var mapOptions = {
        center: new google.maps.LatLng(37.7831, -122.4039),
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById('map'), mapOptions);

    var markerOptions = {
        position: new google.maps.LatLng(37.7831, -122.4039)
    };
    var marker = new google.maps.Marker(markerOptions);
    marker.setMap(map);
</script>
Markers

案例三:info_windows(可以扩展大量的点,并且添加信息什么的)

<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map"></div>
<style type="text/css">
    html, body, #map {
      height: 100%;
      margin: 0;
    }
</style>

<script>
    var mapOptions = {
        center: new google.maps.LatLng(37.7831, -122.4039),
        zoom: 12,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById('map'), mapOptions);

    var markerOptions = {
        position: new google.maps.LatLng(37.7831, -122.4039),
        map: map
    };
    var marker = new google.maps.Marker(markerOptions);
    marker.setMap(map);

    var infoWindowOptions = {
        content: 'Moscone Is Here!'
    };

    var infoWindow = new google.maps.InfoWindow(infoWindowOptions);
    google.maps.event.addListener(marker,'click',function(e){
      infoWindow.open(map, marker);
    });
</script>
info_windows
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,868评论 18 139
  • WebSocket-Swift Starscream的使用 WebSocket 是 HTML5 一种新的协议。它实...
    香橙柚子阅读 24,057评论 8 183
  • Swift版本点击这里欢迎加入QQ群交流: 594119878最新更新日期:18-09-17 About A cu...
    ylgwhyh阅读 25,522评论 7 249
  • 这种人 总是为了自己而活 好吃优先 好衣先穿 好用早试 钱包她揣 几个方面来琢磨别人 幸福自己感受 她总以为 这一...
    旖旎i阅读 196评论 2 9
  • 千里的月光 皎洁了忧伤 借酒一杯回眸望 回忆费思量 心事为谁怅霜夜怎么凉 阁楼之上谁的窗 红烛微微亮 情字怎么尝 ...
    夜已空阅读 101评论 2 4