I am creating my overlay as shown below
 
*var testOverlay = new myOverlay(marker.position,infobox.innerHTML);*
 
Below is my overlay code, where onAdd() , draw and onRemove90 is defined.  
But simetime I see that draw is getting null object error when accessing 
this._div in the draw() function?  I have see some example codes, where 
this._div is created in the draw function and no onAdd() function. why? 
should i do that same thing to avoid null value for this._div in draw 
function?
 
could there be anycase draw() is called before onAdd().  

*myOverlay.prototype = new google.maps.OverlayView();
myOverlay.prototype.onAdd = function() {    // Create the DIV and set some 
basic attributes.
var div = document.createElement('DIV');
div.style.position = "absolute";  
div.style.cursor = "pointer";
// Create an anthoe DIV element for text and attach it to the out DIV.
 var contentDiv = document.createElement("DIV");
 contentDiv.innerHTML = this.html;
 div.appendChild(contentDiv);
 div.cDiv = contentDiv;*

*// Set the overlay's div_ property to this DIV
 this.div_ = div;*

*// We add an overlay to a map via one of the map's panes.
// We'll add this overlay to the overlayImage pane.
 var panes = this.getPanes();
 panes.floatPane.appendChild(this.div_);
};*

*myOverlay.prototype.draw = function() { 
 var p;
 p = this.getProjection().fromLatLngToDivPixel(this.latLng);
    var pNE = 
this.getProjection().fromLatLngToDivPixel(map.getBounds().getNorthEast());
 var pSW = 
this.getProjection().fromLatLngToDivPixel(map.getBounds().getSouthWest());
  
 var offSetX = 25;
 var offSetY = 25;   
   
 if(pNE.x < p.x + 300){
  offSetX = -325;
 }
   
 if(pSW.y < p.y + 200){
  offSetY = -225;
 }
  
 if (p) {
  this.div_.style.left = (p.x + offSetX)+ "px";
  this.div_.style.top = (p.y + offSetY) + "px";   
  } *

*};
myOverlay.prototype.onRemove = function() {
  this.div_.parentNode.removeChild(this.div_);
  this.div_ = null;
};*

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-maps-js-api-v3/-/EvWsTPygNxwJ.
To post to this group, send email to google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to