首页 > 代码库 > how to add borders for a google map marker 谷歌地图 自定义图钉
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‘;
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‘;
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。