自定义地图怎么做成html,自定义html为谷歌地图制作标记

好吧,似乎Custom Overlays会做我想要的。这是ping层:

function PingLayer(bounds, map) {

this.bounds = bounds;

this.setMap(map);

}

PingLayer.prototype = new google.maps.OverlayView();

PingLayer.prototype.onAdd = function() {

var div = document.createElement('DIV');

div.className = "ping";

this.getPanes().overlayLayer.appendChild(div);

div.appendChild(document.createElement("DIV"))

this.div = div;

setTimeout(function(){div.className += " startPing"}, 10);

}

PingLayer.prototype.draw = function() {

var overlayProjection = this.getProjection();

var sw = overlayProjection.fromLatLngToDivPixel(this.bounds.getSouthWest());

var ne = overlayProjection.fromLatLngToDivPixel(this.bounds.getNorthEast());

var div = this.div;

div.style.left = sw.x - 60 + 'px';

div.style.top = ne.y - 65 + 'px';

}这是将em添加到地图的方法:

var swBound = new google.maps.LatLng(lat, lng);

var neBound = new google.maps.LatLng(lat, lng);

var bounds = new google.maps.LatLngBounds(swBound, neBound);

new PingLayer(bounds, map);这是做动画的CSS:

.ping {

position: absolute;

width: 100px;

height: 100px;

}

.ping div {

top: 50px;

left: 50px;

position: relative;

width: 10px;

height: 10px;

border-radius: 50%;

-moz-border-radius: 50%;

-webkit-border-radius: 50%;

background: none;

border: solid 5px #000;

text-align: center;

font-size: 20px;

color: #fff;

-moz-transition-property: width, height, top, left, opacity;

-moz-transition-duration: 2s;

}

.ping.startPing div{

width: 100px;

height: 100px;

top: 0;

left: 0;

opacity: 0;

-moz-transition-duration: 2s;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值