Changeset 107
- Timestamp:
- 05/17/06 13:21:57 (3 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Layer/Marker.js (modified) (2 diffs)
- trunk/openlayers/lib/OpenLayers/Marker.js (modified) (1 diff)
- trunk/openlayers/markers.html (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Layer/Marker.js
r102 r107 4 4 5 5 // markers: store internal marker list 6 markers: null,6 markers: [], 7 7 8 8 initialize: function(name) { … … 11 11 12 12 // Implement this. It may not need to do anything usually. 13 moveTo:function(bounds,zoomChanged) { 14 13 moveTo: function(bounds,zoomChanged) { 14 if (zoomChanged) { 15 this.div.innerHTML=""; 16 for(i=0; i < this.markers.length; i++) { 17 this.drawMarker(this.markers[i]); 18 } 19 } 15 20 }, 16 addMarker: function(marker) {21 addMarker: function(marker) { 17 22 this.markers.append(marker); 23 if (this.map && this.map.getExtent()) { 24 this.drawMarker(marker); 25 } 26 }, 27 drawMarker: function(marker) { 18 28 var resolution = this.map.getResolution(); 19 29 var extent = this.map.getExtent(); 20 30 var pixel = new OpenLayers.Pixel( 21 resolution * (this.lonlat.lon - extent.minlon),22 resolution * (extent.maxlat - this.lonlat.lat)31 1/resolution * (marker.lonlat.lon - extent.minlon), 32 1/resolution * (extent.maxlat - marker.lonlat.lat) 23 33 ); 24 34 var m = marker.generateMarker(pixel); 25 35 this.div.appendChild(m); 26 } ,36 } 27 37 }); trunk/openlayers/lib/OpenLayers/Marker.js
r102 r107 29 29 }, 30 30 generateMarker: function(pixel) { 31 var markerObject; 32 // Create a div here, and set the location to the pixel above 31 // Create a div here, and set the location to the pixel above modified 32 // by the icon size. 33 var markerObject = OpenLayers.Util.createImage( 34 this.icon.url, 35 this.icon.size, 36 new OpenLayers.Pixel( 37 pixel.x-(this.icon.size.w/2), 38 pixel.y-this.icon.size.h) 39 ); 33 40 return markerObject; 34 41 }
