Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(window){
- function CustomMarker(__settings__) {
- "use strict";
- this.latlng = __settings__.latlng;
- this.args = __settings__.args;
- this.template = __settings__.template;
- this.setMap(__settings__.map);
- this.width = checkSize(__settings__.width);
- this.height = checkSize(__settings__.height);
- this.callBackClickListener = __settings__.callBackClickListener
- }
- function checkSize (__val__){
- return (!String(__val__).indexOf('px') !== -1) ? String(__val__+"px") : __val__;
- }
- CustomMarker.prototype = new google.maps.OverlayView();
- CustomMarker.prototype.draw = function() {
- var self = this;
- var div = this.div;
- if (!div) {
- div = this.div = document.createElement('div');
- div.className = 'custom_marker_item';
- div.style.position = 'absolute';
- div.style.cursor = 'pointer';
- div.style.width = this.width ;
- div.style.height = this.height;
- if(this.args.zIndex){
- div.style.zIndex = this.args.zIndex;
- }
- if(!this.template){
- div.style.background = 'blue';
- }else{
- div.innerHTML = this.template;
- }
- if (typeof(self.args.marker_id) !== 'undefined') {
- div.dataset.marker_id = self.args.marker_id;
- }
- var self = this;
- google.maps.event.addDomListener(div, "click", function(event) {
- google.maps.event.trigger(self, "click");
- // function name and parameters to pass
- var fnc = self.callBackClickListener;
- var fnparams = [self];
- // find object
- fnc.apply(null, fnparams);
- });
- var panes = this.getPanes();
- panes.overlayImage.appendChild(div);
- }
- var point = this.getProjection().fromLatLngToDivPixel(this.latlng);
- if (point) {
- var moveTop = (this.args.top) ? this.args.top : 0;
- var moveLeft = (this.args.left) ? this.args.left : 0;
- div.style.left = (point.x - moveLeft ) + 'px';
- div.style.top = (point.y - moveTop) + 'px';
- }
- };
- CustomMarker.prototype.remove = function() {
- if (this.div) {
- this.div.parentNode.removeChild(this.div);
- this.div = null;
- }
- };
- CustomMarker.prototype.getPosition = function() {
- return this.latlng;
- };
- window.CustomMarker = CustomMarker;
- }(window));
- var template = $('#template-icon-maps').html();
- var dataMarker = {
- latlng:myPosition,
- map:myMas,
- args:{
- marker_id: myId,
- left: 16,
- top: 32,
- zIndex: myIndex
- },
- template:html,
- width: 32,
- height:32,
- callBackClickListener: myCallbackFunction
- };
- var overlay = new CustomMarker(dataMarker);
- function myCallbackFunction (__args__){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement