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>

 

效果如下:

如何在 Google 地图中添加标记和说明的更多相关文章

  1. 如何在Google Map中处理大量标记(ASP.NET)(转)

    如何在Google Map中处理大量标记(ASP.NET)(原创-翻译) Posted on 2010-07-29 22:04 Happy Coding 阅读(8827) 评论(8) 编辑 收藏 在你 ...

  2. google maps js v3 api教程(2) -- 在地图上添加标记

    原文链接 google maps javascript官方文档:https://developers.google.com/maps/documentation/javascript/ 我们在创建地图 ...

  3. 如何在google test中指定只运行一部分测试

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:如何在google test中指定只运行一部分测试.

  4. 如何在VUE项目中添加ESLint

    如何在VUE项目中添加ESLint 1. 首先在项目的根目录下 新建 .eslintrc.js文件,其配置规则可以如下:(自己小整理了一份),所有的代码如下: // https://eslint.or ...

  5. 如何在Android Studio中添加注释模板信息?

    如何在Android Studio中添加注释模板信息? 在开发程序的时候,我们一般都会给文件自动添加上一些关于文件的注释信息,比如开发者的名字,开发的时间,开发者的联系方式等等.那么在android ...

  6. 如何在RCP程序中添加一个banner栏

    前言:这段时间还算比较空闲,我准备把过去做过的有些形形色色,甚至有些奇怪的研究总结一下,也许刚好有人用的着也不一定,不枉为之抓耳挠腮的时光和浪费的电力.以前有个客户提出要在RCP程序中添加一个bann ...

  7. 文章翻译:ABP如何在EF core中添加数据过滤器

    原文地址:https://aspnetboilerplate.com/Pages/Documents/Articles%5CHow-To%5Cadd-custom-data-filter-ef-cor ...

  8. [译]如何在Unity编辑器中添加你自己的工具

    在这篇教程中你会学习如何扩展你的Unity3D编辑器,以便在你的项目中更好的使用它.你将会学习如何绘制你自己的gizmo,用代码来实现创建和删除物体,创建编辑器窗口,使用组件,并且允许用户撤销他们所作 ...

  9. 如何在web项目中添加javamelody monitoring 监控。

    1.在工程的maven pom中添加依赖javamelody-core <!-- monitoring监控 --><!-- https://mvnrepository.com/art ...

随机推荐

  1. jumpserver0.4.0与python3版本安装

    环境: 系统:CentOS 6.5 Python版本:Python3.6 安装目录:/Data/apps/ 一. 环境准备: 1.  基本工具库: # yum -y install sqlite-de ...

  2. NEO4J (二)

    README 整理 kernel.impl.coreapi 这个包包含核心API的直接实现.核心API是org.neo4j中定义的API.graphdb及其子包. 这里的类是实现细节,可能会在不通知的 ...

  3. fiddler笔记:统计选项卡(Statistics)

    Request Count 选中的Session数. Bytes sent Http请求头和请求体中向外发送的字节总数. Bytes received HTTP请求头和请求体中接收到的所有字节数. R ...

  4. 装饰器中functools的用处

    定义一个最简单的装饰器 def user_login_data(f): def wrapper(*args, **kwargs): return f(*args, **kwargs) return w ...

  5. redis集群搭建及一些问题

    redis 1.简化版redis (本套Redis集群为简化版安装部署,只需解压至普通用户家目录下或者任意目录,解压后修改脚本,执行脚本后即可使用.) 注意,此版本需要在redis配置文件中添加 pr ...

  6. Entity的约束

    在DBContext的OnModelCreating()方法中调用上面的那个类 1.Infrastruture的Database文件夹建立Entityconfiguretions的文件夹 2.MyCo ...

  7. Javascript中new的作用

    关于js中new关键字的理解,先来看个例子:像这样创建实例时使用new与不使用new有什么区别????function ParasiticPerson(name, age, job) {    var ...

  8. luogu2568GCD题解--欧拉函数

    题目链接 https://www.luogu.org/problemnew/show/P2568 分析 题目即求\(\sum_{i=1}^N \sum_{j=1}^N [gcd(i,j)\) \(is ...

  9. 充值css样式

    @charset "utf-8"; /*reset CSS*/ body,ul,ol,dl,dd,h1,h2,h3,h4,h5,h6,figure,form,fieldset,le ...

  10. 客户想要的 vs 客户实际预算:漫画解读软件开发模式 ​​​​

    转自:http://blog.jobbole.com/113230/ 1913 年,美利坚工业之神——亨利福特,发明了世界上第一条流水线,汽车工业从此进入了大规模生产的时代.丰田公司提出的丰田生产系统 ...