惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
L
LangChain Blog
博客园_首页
J
Java Code Geeks
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
WordPress大学
WordPress大学
V
Visual Studio Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
酷 壳 – CoolShell
酷 壳 – CoolShell
Recent Announcements
Recent Announcements
C
Check Point Blog
IT之家
IT之家
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
D
Docker
有赞技术团队
有赞技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
I
InfoQ

博客园 - rosanshao

使用sc 命令写脚本 添加和删除服务 简单应用 Win 10激活 couchbase map reduce StartWith 测试 笔记,转 Couchbase II( View And Index) Couchbase I SqlIO优化 死锁检测 MemCached 安装笔记 Asp.Net异步编程-使用了异步,性能就提升了吗? Autofac Mvc Webapi注入笔记 Sql Server 2005/2008 SqlCacheDependency查询通知的使用总结 WCF .NET REST调用方式 WCF HelpPage 和自动根据头返回JSON XML .net 4.0 新特性 Linq 并行化处理 IIS 假死状态处理 jQuery插件开发 StatusCode - rosanshao - 博客园
gmap
rosanshao · 2010-09-18 · via 博客园 - rosanshao

Google Map Api 添加自定叠加层实现须要实现GOverlay接口,须要实现以下几个方法. •initialize() called in response to GMap2.addOverlay() •remove() called in response to GMap2.removeOverlay() •copy() to allow templating of the new overlay •redraw() called in response to a display change within the map 以下,为实现自定文字标注的例子. 1 function TextOverlay(latLng, html) { 2 this.latLng = latLng; 3 this.html = html; 4 } 5 TextOverlay.prototype = new google.maps.Overlay(); 6 TextOverlay.prototype.initialize = function(map) { 7 var div = document.createElement("div"); 8 div.style.position = "absolute"; 9 div.style.width = "1000px"; 10 div.innerHTML = this.html; 11 map.getPane(G_MAP_MAP_PANE).appendChild(div); 12 this.map_ = map; 13 this.div_ = div; 14 this.redraw(true); 15 } 16 TextOverlay.prototype.remove = function() { 17 this.div_.parentNode.removeChild(this.div_); 18 } 19 TextOverlay.prototype.copy = function() { 20 return new TextOverlay(this.latLng, this.html); 21 } 22 TextOverlay.prototype.redraw = function(force) { 23 if (!force) { 24 return; 25 } 26 var position = this.map_.fromLatLngToDivPixel(this.latLng); 27 this.div_.style.left = position.x + "px"; 28 this.div_.style.top = position.y + "px"; 29 } 30 TextOverlay.prototype.setLatLng = function(latLng) { 31 this.latLng = latLng; 32 this.redraw(true); 33 } 34 TextOverlay.prototype.getLatLng = function() { 35 return this.latLng; 36 } 37 $(function() { 38 var latLng = map.getCenter(); 39 var textOverlay = new TextOverlay(latLng, "我爱你!"); 40 map.addOverlay(textOverlay); 41 });

posted on 2010-09-18 20:19  rosanshao  阅读(439)  评论()    收藏  举报