代码:

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">var markers = [{"title": 'Aksa Beach',"lat": '19.1759668',"lng": '72.79504659999998',"description": 'Aksa Beach is a popular beach and a vacation spot in Aksa village at Malad, Mumbai.'},{"title": 'Juhu Beach',"lat": '19.0883595',"lng": '72.82652380000002',"description": 'Juhu Beach is one of favourite tourist attractions situated in Mumbai.'},{"title": 'Girgaum Beach',"lat": '18.9542149',"lng": '72.81203529999993',"description": 'Girgaum Beach commonly known as just Chaupati is one of the most famous public beaches in Mumbai.'},{"title": 'Jijamata Udyan',"lat": '18.979006',"lng": '72.83388300000001',"description": 'Jijamata Udyan is situated near Byculla station is famous as Mumbai (Bombay) Zoo.'},{"title": 'Sanjay Gandhi National Park',"lat": '19.2147067',"lng": '72.91062020000004',"description": 'Sanjay Gandhi National Park is a large protected area in the northern part of Mumbai city.'}];window.onload = function () {LoadMap();}function LoadMap() {var mapOptions = {center: new google.maps.LatLng(markers[0].lat, markers[0].lng),zoom: 10,mapTypeId: google.maps.MapTypeId.ROADMAP};var map = new google.maps.Map(document.getElementById("dvMap"), mapOptions);//Create and open InfoWindow.var infoWindow = new google.maps.InfoWindow();for (var i = 0; i < markers.length; i++) {var data = markers[i];var myLatlng = new google.maps.LatLng(data.lat, data.lng);var marker = new google.maps.Marker({position: myLatlng,map: map,title: data.title});//Attach click event to the marker.(function (marker, data) {google.maps.event.addListener(marker, "click", function (e) {//Wrap the content inside an HTML DIV in order to set height and width of InfoWindow.infoWindow.setContent("<div style = 'width:200px;min-height:40px'>" + data.description + "</div>");infoWindow.open(map, marker);});})(marker, data);}}
</script>
<div id="dvMap" style="width: 300px; height: 400px">
</div>
Screenshot

原文:http://www.aspsnippets.com/Articles/Google-Maps-API-V3-Add-click-event-listener-to-all-multiple-markers.aspx
justcode.ikeepstudying.com

谷歌地图添加点击事件 Google Maps API V3: Add click event listener to all (multiple) marker相关推荐

  1. Android 关于谷歌地图版本的选择(Google Maps API )

    引用:Google Maps JavaScript API 可让您在网页中嵌入 Google Maps.此 API 的第 3 版是专为移动设备设计的,速度更快,更适用:它同时也适用于传统的桌面浏览器应 ...

  2. Google Maps API V3 之绘图库

    绘图库 本文档中的概念仅适用于 google.maps.drawing 库中提供的地图项.默认情况下,系统在加载 Maps JavaScript API 时不会加载该库,您必须使用 libraries ...

  3. Google Maps API V3 之绘图库 信息窗口

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  4. Google Maps API v3:如何删除所有标记?

    本文翻译自:Google Maps API v3: How to remove all markers? In Google Maps API v2, if I wanted to remove al ...

  5. Google Maps API V3学习--- 简单地图显示

    技术发展日新月异,为了与时俱进,不让自己很快的落伍,正好项目有所需要,就学习了下 新发布的Google Maps API V3. V3相对于V2存在许多改变,比如在地图的加载上,尤其是手机浏览器访问的 ...

  6. Google Maps API V3: 通过邮编获取经纬度 Get Location (Latitude and Longitude) from Zip Cod

    In this article I will explain with an example, how to get Location Coordinates i.e. Latitude and Lo ...

  7. Google Maps API V3 之 图层

    图层概述 图层是地图上的对象,包含一个或多个单独项,但可作为一个整体进行操作.图层通常反映了您添加到地图上用于指定公共关联的对象集合.Maps API 会通过以下方法管理图层内对象的显示形式:将图层的 ...

  8. echarts 地图 scatter点击事件_React实现高亮可点击地图

    目前越来越多的项目中开始使用地图,而对地图的需求也不仅仅是简单的纯展示,更多了各种各样的交互功能.今天这篇文章主要介绍的就react中通过Echarts实现一个高亮可点击的省市地图.接下来先看看效果图 ...

  9. openlayers 给数据点(散点)添加点击事件 和hover事件

    前言:由于本人也是最近才开始学习openlayers,如说明的有所不对,请在评论区指出. 1.点击事件 /*** 捕捉点击事件*/featureClick(callback) {let _this = ...

最新文章

  1. Java设计模式—模板方法模式
  2. skynet 报错 skynet 服务缺陷 Lua死循环
  3. pdf html5 阅读进度,HTML5的进度条progress元素
  4. php时间戳防盗链,金山云-文档中心-设置时间戳+共享密钥防盗链
  5. 使用内存映射文件获取巨大的矩阵
  6. LeetCode 2002. 两个回文子序列长度的最大乘积(状态压缩+枚举状态子集+预处理)
  7. 《给年青数学人的信》:为何学数学?
  8. Java字符串分割到map_如何在Java中按空格分割字符串并以键值形式存储在map中?...
  9. centeros下安装python
  10. 运用高斯核模型进行最小二乘回归_数据科学 | 第8讲:模型选择与正则化
  11. lodop转到其他html页面,vue项目中使用Lodop实现批量打印html页面和pdf文件
  12. Word文档多级标题自动编号设置
  13. 浅谈Linux管线命令grep
  14. List集合对象去重及按属性去重的8种方法
  15. 【前端】【HTML+CSS+JavaScript(JS)】简易工资计算器的实现
  16. python接口自动化测试视频教程百度云全集_python自动化运维测试框架实战视频教程百度云资源...
  17. 20175212童皓桢 《Java程序设计》第十周学习总结
  18. 美国康奈尔大学BioNB441元胞自动机MATLAB应用
  19. 做了一个以防小憩被媳妇打扰的快捷指令
  20. 前端vue基于onlyoffice实现在线预览

热门文章

  1. Bad Hair Day(POJ-3250)
  2. 单词查找树(信息学奥赛一本通-T1337)
  3. 45 SD配置-销售凭证设置-分配订单类型/状态参数文件
  4. 18 MM配置-BP业务伙伴-定义业务伙伴角色分组
  5. linux内核驱动工作队列用法
  6. 时序图如何表现分支_静态时序分析圣经翻译计划——第五章:延迟计算 (上)...
  7. cycleGAN的整体架构+损失函数理解
  8. 相对路径 ‘’,‘/’,‘./‘,‘../‘
  9. Flink java.lang.NoClassDefFoundError: org/apache/flink/api/common/functions/FlatMapFunction
  10. Bootstrap居中显示