在Google Maps 上点击标签显示说明并保持不消失

JS如下:

(function() {

????window.onload = function() {

????????// Creating an object literal containing the properties

????????// we 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 that 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));

????????// Looping through the places array

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

????????????// Adding the marker as usual

????????????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() {

????????????????????var infowindow = new google.maps.InfoWindow({

????????????????????????content: ‘Place number ‘ + i

????????????????????});

????????????????????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>

?

效果如下:

时间: 2024-12-08 23:22:23

在Google Maps 上点击标签显示说明并保持不消失的相关文章

在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.0

Google Maps API显示地图的小示例

来源:http://www.ido321.com/1089.html 效果(新版Firefox中测试): 代码: <!DOCTYPE> <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8"> <title>Google Map</title> <script type="te

Google Maps API V3 之 图层

图层概述 图层是地图上的对象,包含一个或多个单独项,但可作为一个整体进行操作.图层通常反映了您添加到地图上用于指定公共关联的对象集合.Maps API 会通过以下方法管理图层内对象的显示形式:将图层的组成项呈现在一个对象(通常为一个图块叠加层)中并根据地图视口的变化情况进行显示.图层还可以改变地图自身的展示图层,以符合图层样式的方式稍稍改变基本图块.请注意,系统将大部分图层设计为禁止通过其单个对象进行访问,而仅可将其作为一个整体来操作. 要在地图上添加图层,只需调用 setMap() 并向其传递

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

绘图库 本文档中的概念仅适用于 google.maps.drawing 库中提供的地图项.默认情况下,系统在加载 Maps JavaScript API 时不会加载该库,您必须使用 libraries 引导程序参数进行明确指定. http://maps.googleapis.com/maps/api/js?sensor=false&libraries=drawing DrawingManager 类提供了一个图形界面,以供用户在地图上绘制多边形.矩形.折线.圆形和标记.DrawingManage

Google maps library的使用

公司的项目中用到了google地图API, 使用Google API开发就会用到Marker, 用来在google 地图上标注位置 但是google marker使用过程中也有个问题,就是如果在google 地图上标注了大量的Marker, 一个是容易导致google地图加载速度变慢,另一个是marker太多,地图就很 不好看,甚至是看不清楚了,因为你会发现地图就被这些Marker占据了 在Google Maps API中,提供了集群来解决这个问题,也就是MarkerClusterer, 我们之

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

原文链接 google maps javascript官方文档:https://developers.google.com/maps/documentation/javascript/ 我们在创建地图之后,怎么往地图上添加标记呢? google为我们提供了google.maps.Marker这个构造函数,来创建标记. 这个函数有一个object类型的可选参数,常用的成员有: { position: new google.maps.LatLng(lat,lng), //标记的经纬度 map:map

android如果给TextView或EditText的email链接加下划线,并在点击在email连接上可以弹框显示

如何把textview的一些文字加上背景色: Spannable str = new SpannableString("#fdsfdfsdfdsfd#"); Matcher matcher = getEmailPattern().matcher((CharSequence) str); while (matcher.find()) { int start = matcher.start(); int end = matcher.end(); str.setSpan(new Foregr

MyEclipse导入主题文件epf后xml及jsp等页面中点击标签之后显示灰白

MyEclipse导入主题文件epf后xml及jsp等页面中点击标签之后显示灰白,症状如下: 解决方案如下: MyEclipse导入主题文件epf后xml及jsp等页面中点击标签之后显示灰白,布布扣,bubuko.com

点击按钮显示谷歌地图

原文:点击按钮显示谷歌地图 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "