在Google Maps 上点击标签后显示说明

JS如下:

(function() {

    window.onload = function() {

 

        // Creating an object literal containing the properties

        // you want to pass to the map

        var options = {

            zoom: 3,

            center: new google.maps.LatLng(37.09, -95.71),

            mapTypeId: google.maps.MapTypeId.ROADMAP

        };

 

        // Creating the map

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

 

        // Creating an array which will contain the coordinates

        // for New York, San Francisco and Seattle

        var places = [];

 

        // Adding a LatLng object for each city

        places.push(new google.maps.LatLng(40.756, -73.986));

        places.push(new google.maps.LatLng(37.775, -122.419));

        places.push(new google.maps.LatLng(47.620, -122.347));

 

        // Creating a variable that will hold the InfoWindow object

        var infowindow;

 

        // Looping through the places array

        for (var i = 0; i < places.length; i++) {

 

            // Adding the markers

            var marker = new google.maps.Marker({

                position: places[i],

                map: map,

                title: 'Place number ' + i

            });

 

            // Wrapping the event listener inside an anonymous function

            // that we immediately invoke and passes the variable i to.

            (function(i, marker) {

 

                // Creating the event listener. It now has access to the values of

                // i and marker as they were during its creation

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

 

                    if (!infowindow) {

                        infowindow = new google.maps.InfoWindow();

                    }

 

                    // Setting the content of the InfoWindow

                    infowindow.setContent('Place number ' + i);

 

                    // Tying the InfoWindow to the marker

                    infowindow.open(map, marker);

 

                });

 

            })(i, 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>

 

效果如下:

转载于:https://www.cnblogs.com/my4piano/p/5327140.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/418730.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

static class 静态类(Java)

https://www.cnblogs.com/KingIceMou/p/7823918.html

前端学习(1851)vue之电商管理系统电商系统配置ssh

1登录到码云 2设置 生成公钥 3添加公钥 验证成功

MiseringThread.java 解析页面线程

MiseringThread.java 解析页面线程 http://injavawetrust.iteye.com package com.iteye.injavawetrust.miner;import java.util.Set;import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory;/*** 解析页面线程* author InJavaWeTrust**/ public…

前端学习(1852)vue之电商管理系统电商系统托管码云上

1新建仓库 2执行命令 3添加git add . 3git add files 提交

mysql的left join和inner join的效率对比,以及如何优化

https://blog.csdn.net/LJFPHP/article/details/88635755 http://www.bamn.cn/News/views/285

前端学习(1853)vue之电商管理系统电商系统之git安装

1下载安装包 git官网&#xff1a; https://git-scm.com/download/win git阿里镜像&#xff1a; https://npm.taobao.org/mirrors/git-for-windows/ 2安装 基本傻瓜程序 上图红框内的选项是默认勾选的&#xff0c;建议不要动。绿色框1是决定是否在桌面创建快捷方式的。绿色框…

Beaglebone Black教程Beaglebone Black的引脚分配

Beaglebone Black教程Beaglebone Black的引脚分配 Beaglebone Black的引脚分配 绝大多数的微型开发平台都提供了一些称为GPIO的输入输出端口。这些端口可以让你使用软件和硬件来控制一些电子的东西&#xff0c;每个端口都被赋予了一个特定的功能——模拟或数字。大多数的微控制…

Mybatis的mapper标签 namespace属性说明

https://blog.csdn.net/qq_33530388/article/details/71194518

前端学习(1854)vue之电商管理系统电商系统之git push后出现错误 ![rejected] master -> master(non-fast-forward) error:failed t

! [rejected] master -> master (non-fast-forward) error: failed to push some refs to https://gitee.com/geyaoisgeyao/vue_shop.git 解决办法 本地创建了一个project 并在GitHub上创建了一个仓库&#xff0c;想要将本地的仓库链接到远程仓库 我用的是如下方法…

iOS Social框架

现在很多应用都内置“社交分享”功能&#xff0c;可以将看到的新闻、博客、广告等内容分享到微博、微信、QQ、空间等&#xff0c;其实从iOS6.0开始苹果官方就内置了Social.framework专门来实现社交分享功能&#xff0c;利用这个框架开发者只需要几句代码就可以实现内容分享。下…

前端学习(1855)vue之电商管理系统电商系统之安装mysql出现VCRUNTIME140_1.dll

由于找不到VCRUNTIME140_1.dll&#xff0c;无法继续执行代码。重新安装程序可能会解决此问题 链接: https://pan.baidu.com/s/1eDs_N5zM-1pvByyfvm0S3Q 提取码: fh91 安装插件即可

MyBatis的foreach查询(List、Array、Map)

https://www.iteye.com/blog/xh32t03-2361336

前端学习(1856)vue之电商管理系统电商系统之安装mysql出现mysql报错:Can’t start server: Bind on TCP/IP port: 通常每个套接字地址(协议/网络地址

2020-07-26T11:44:29.778919Z 0 [ERROR] [MY-010262] [Server] Cant start server: Bind on TCP/IP port: 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。

mybatis数组和集合的长度判断及插入

http://www.mamicode.com/info-detail-2377759.html

简单存取款机的实现---控制输入变量的规则

转载于:https://www.cnblogs.com/quanby/p/5335527.html

前端学习(1854)vue之电商管理系统电商系统之安装mysql

本地安装好数据库 source导入命令 source d:/mydb.sql

ueditor 上传图片或者视频报错 413 Request Entity Too Large

https://blog.csdn.net/cominglately/article/details/79773697

前端学习(1857)vue之电商管理系统电商系统之配置api接口服务器并用postman调试接口

# 1. 电商管理后台 API 接口文档## 1.1. API V1 接口说明- 接口基准地址&#xff1a;http://127.0.0.1:8888/api/private/v1/ - 服务端已开启 CORS 跨域支持 - API V1 认证统一使用 Token 认证 - 需要授权的 API &#xff0c;必须在请求头中使用 Authorization 字段提供 token …

[原]Jenkins(十二)---jenkins管理员用户无法登陆解决办法Access Denied

/** * lihaibo * 文章内容都是根据自己工作情况实践得出。 *如有错误&#xff0c;请指正 * 版权声明&#xff1a;本博客欢迎转发&#xff0c;但请保留原作者信息! http://www.cnblogs.com/horizonli/p/5337295.html */ 一、问题出现的原因&#xff1a; 如下图&#xff0c;在…

quartz定时任务时间设置

https://www.cnblogs.com/a8457013/p/8515939.html