JS如下:

(function() {

    window.onload = function() {

        // Creating an object literal containing the properties

        // we want to pass to the map

        var options = {

            zoom: 12,

            center: new google.maps.LatLng(40.7257, -74.0047),

            mapTypeId: google.maps.MapTypeId.ROADMAP

        };

        // Creating the map

        var map = new google.maps.Map(document.getElementById('map'), options);

        // Adding a marker to the map

        var marker = new google.maps.Marker({

            position: new google.maps.LatLng(40.7257, -74.0047),

            map: map,

            title: 'Click me',

            //icon: 'http://gmaps-samples.googlecode.com/svn/trunk/markers/blue/blank.png'

        });

        

        var infowindow = new google.maps.InfoWindow({

        content:'<div class="info">Hello world</div>'

        });

        

        infowindow.open(map, marker);

        

        // Adding a click event to the marker

/*        google.maps.event.addListener(marker, 'click', function() {

        // Calling the open method of the infoWindow

        infowindow.open(map, marker);

        });*/

    };

})();

 

CSS如下:

body
{

font-family:
Verdana,
Geneva,
Arial,
Helvetica,
sans-serif;

font-size:
small;

background:
#fff;

}

#map
{

width:
100%;

height:
500px;

border:
1px
solid
#000;

}

.info
{

width:
250px;

}

 

HTML如下:

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>My first map</title>

<link type="text/css" href="css/style.css" rel="stylesheet" media="all" />

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript" src="js/map.js"></script>

</head>

<body>

<h1>My first map</h1>

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

</body>

</html>

 

效果如下:

最新文章

  1. nodejs操作arduino入门(javascript操作底层硬件)
  2. java文章显示内容部分(将html转成纯文本)
  3. 【VB6】VB6实现拖拽
  4. Android MMS 之APN
  5. 2016值得关注的语言平台、JS框架
  6. node exports和module.exports区别
  7. ndroid网络(4):HttpClient必经之路----使用线程安全的单例模式HttpClient,及HttpClient和Application的融合
  8. 利用Oracle数据库的UTL_SMTP发送HTML 邮件
  9. 使用 neon-wallet-db + neon-js + NEO-cli /rpc 搭建轻钱包服务端
  10. php框架中的phalcon框架的安装,及初步认识,从表单提交简单的数据到数据库中
  11. 团队作业第六次-团队Github实战训练
  12. 老司机带路:《axios从入门到开车 嘀嘀~~》
  13. 第14章 添加JavaScript客户端 - Identity Server 4 中文文档(v1.0.0)
  14. sql server 将两列数据合并到一列 拼接
  15. latex 导入pdf
  16. 牛客网_Go语言相关练习_判断&amp;选择题(6)
  17. AJAX缓存清理
  18. sap component 导航 链接
  19. oracle 常用字符串函数
  20. django之创建第7-2个项目-url配置分离

热门文章

  1. lua语法介绍(二)
  2. #【Python】【demo实验34】【练习实例】【设置文本的颜色】
  3. java源码--ArrayList
  4. LC 202. Happy Number
  5. Codeforces 718A Efim and Strange Grade 程序分析
  6. 【静态延迟加载】self关键字和static关键字的区别
  7. 图像识别tesseract-ocr
  8. HTML form表单中action的正确写法
  9. 我的第一个python web开发框架(2)——第一个Hello World
  10. 作业12:List集合类