google搜了很久都没找到符合v3版本的google maps自定义图标,可以让图标使用自己的html,都是V2版本的,依靠重写google api属性来完成.

然后就找了个jquery下的google maps插件: GMAP3(http://gmap3.net)

经过研究发现...这货很方便,而且我也实现了自己的图标!

我的自定义图标使用的是bootstrap插件:font-awesome中的icon.

首先,引入

<link href="bootstrap.css" rel="stylesheet"/>
<link href="bootstrap-responsive.css" rel="stylesheet"/>
<link href="font-awesome.css" rel="stylesheet"/>
<script type="text/javascript" src="jquery.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?&sensor=false" type="text/javascript"></script>
<script type="text/javascript" src="gmap3.js"></script>

然后简历一个json

var $values = [
{
latLng: [48.8620722, 2.352047], data: "Paris !",
options: {
icon: "marker_icon_bg.png",
content: '<i style="color:#fff" class="icon-food"></i>',
offset: {
y: -32,
x: -6
}
}
},
{
address: "86000 Poitiers, France", data: "Poitiers : great city !",
options: {
icon: "marker_icon_bg.png",
content: '<i style="color:#fff" class="icon-picture"></i>',
offset: {
y: -32,
x: -8
}
}
},
{
address: "66000 Perpignan, France", data: "Perpignan ! <br> GO USAP !",
options: {
icon: "marker_icon_bg.png",
content: '<i style="color:#fff" class="icon-building"></i>',
offset: {
y: -32,
x: -6
}
}
}
];

直接调用gmap3的方法:

$(function () {

            $('#map_canvas').gmap3({
map: {
options: {
center: [46.578498, 2.457275],
zoom: 5
}
},
marker: {
values: $values,
options: {
draggable: false
},
events: {
mouseover: function (marker, event, context) {
var map = $(this).gmap3("get"),
infowindow = $(this).gmap3({ get: { name: "infowindow" } });
if (infowindow) {
infowindow.open(map, marker);
infowindow.setContent(context.data);
} else {
$(this).gmap3({
infowindow: {
anchor: marker,
options: { content: context.data }
}
});
}
},
mouseout: function () {
var infowindow = $(this).gmap3({ get: { name: "infowindow" } });
if (infowindow) {
infowindow.close();
}
}
}
},
overlay: {
values: $values
}
});
});

Body部分:

<body>
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>

相当方便!直接产生了地标背景上出现图标,而且还是json方式的,方便我们生成!

google maps v3 添加自定义图标(marker,overlay)的更多相关文章

  1. Google Maps V3 之 路线服务

    概述 您可以使用 DirectionsService 对象计算路线(使用各种交通方式).此对象与 Google Maps API 路线服务进行通信,该服务会接收路线请求并返回计算的结果.您可以自行处理 ...

  2. [Google Maps API 3]Marker从Clusterer中分离及Marker置于Cluster上一层的解决办法

    在Google Maps API的使用中,经常用到Clusterer来避免过密的Marker显示.但仔细看一下Clusterer的设置参数中并没有直接将某些Marker除外的方法,那遇到这样的需求,怎 ...

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

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

  4. Google Maps API V3 之 图层

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

  5. Google Maps API V3 之 路线服务

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

  6. ☀【移动】Google Maps JavaScript API v3

    Google Maps JavaScript API v3https://developers.google.com/maps/documentation/javascript/tutorial?hl ...

  7. google maps js v3 api教程(3) -- 创建infowindow

    原文地址 前面我们学习了地图和标记的创建.那么今天我们来学习怎样在地图上显示一个窗口(infowindow) infowindow构造函数为:InfoWindow(opts?:InfoWindowOp ...

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

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

  9. [转]MBTiles 离线地图演示 - 基于 Google Maps JavaScript API v3 + SQLite

    MBTiles 是一种地图瓦片存储的数据规范,它使用SQLite数据库,可大大提高海量地图瓦片的读取速度,比通过瓦片文件方式的读取要快很多,适用于Android.IPhone等智能手机的离线地图存储. ...

随机推荐

  1. 转:ASP.NET中的SESSION实现与操作方法

    在ASP.NET中,状态的保持方法大致有:ApplicationState,SessionState,Cookie,配置文件,缓存. ApplicationState 的典型应用如存储全局数据. Se ...

  2. linux(ubuntu)和windows下面快速搭建android开发环境

    在windows和linux下面搭建android开发环境,一般要安装以下几个软件: 1.JDK安装 2.Eclipse安装 3.Android SDK安装 4.在eclipse里面安装ADT 5.e ...

  3. Factory Method模式

    Factory Method(工厂方法)模式属于GoF设计模式中的创建型分组,它用于在不之制定待创建对象的具体类的情况下创建对象.--<asp.net设计模式> 说白了就是一个人想要出国旅 ...

  4. Poj 2993 Emag eht htiw Em Pleh

    1.Link: http://poj.org/problem?id=2993 2.Content: Emag eht htiw Em Pleh Time Limit: 1000MS   Memory ...

  5. DTCMS视频模版更改,

    1.去掉style.css中视频的高度 .video-box{ position:relative; width:100%; height:473px; _clear:both; _display:i ...

  6. DTCMS获取栏目子类

    <%set DataTable categoryList=get_category_child_list(channel,0)%> <%foreach(DataRow cdr in ...

  7. DirectSound学习(二)--流式缓冲区

    使用流式缓冲方式播放波形音频文件比较复杂,主要原因是在只有一个缓冲区提供给用户的前提下,这个缓冲区在提供给声卡播放数据的同是还需要用户不断的定时向其中写入数据.要注意从缓冲区这时是一个环形缓冲区,声音 ...

  8. 用AJAX自定义日历

    需求分析 在一些购物网站中,都会有促销活动,这些活动都在日历上标注出来,如何通过Ajax让日历 通过读取数据库中的信息,正确的把促销活动标注在日历上,本文通过自定义日历来实现这 个问题. 技术难点 日 ...

  9. a标签点击后的虚线框问题

    以前一直用的方法都是: a {outline: none;star:expression(this.onFocus=this.blur());} 后来发现有瑕疵,不完美.体现在页面调用JS动作比较频繁 ...

  10. 九度OJ做题记录 更新.....

    2015年1月7日 20:34:23  题目1007:奥运排序问题 有点意思,以后想另外方法快速做出来 2015年1月7日 21:03:56 有一个技巧就是,写了三个比较函数cmp1,cmp2,cmp ...