how to add borders for a google map marker 谷歌地图 自定义图钉

If you are not satisfied with default Google map Marker ( Default google marker can only be a icon, image or shape ), for example adding a border, then you should use richmarker!

http://google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/

Inside richmarker:

RickMarker extends from google.maps.OverlayView

RichMarker.prototype.onAdd
     
     var panes = this.getPanes();// Returns the panes in which this OverlayView can be rendered. The panes are not initialized until  onAdd  is called by the API.
     panes.overlayMouseTarget.appendChild();// This pane contains elements that receive DOM mouse events, such as the transparent targets for markers. It is above the floatShadow, so that markers in the shadow of the info window can be clickable. (Pane 5).

RichMarker.prototype.draw

       var projection = this.getProjection(); // Returns the  MapCanvasProjection  object associated with this  OverlayView . The projection is not initialized until  onAdd  is called by the API.
       var latLng = (this.get('position'));
       var pos = projection.fromLatLngToDivPixel(latLng);// Computes the pixel coordinates of the given geographical location in the DOM element that holds the draggable map.
       var offset = this.getOffset_();
       this.markerWrapper_.style['top'] = (pos.y + offset.height) + 'px';
       this.markerWrapper_.style['left'] = (pos.x + offset.width) + 'px';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值