From 66edc6dcb7b2b768bc347624ff2843f501c8dcf7 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Wed, 17 May 2006 12:16:23 +0000 Subject: [PATCH] Fill out more of Icon and Marker classes. In the XP world, supposedly we test first -- and I actually did in this case. Kind of a nifty trick: you work out what the function is supposed to do solely from the tests you want to write, and then you go and actually write the code that does it. git-svn-id: http://svn.openlayers.org/trunk/openlayers@87 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Icon.js | 5 +++-- lib/OpenLayers/Marker.js | 33 ++++++++++++++++++++++++++++++--- tests/list-tests.html | 2 ++ tests/test_Icon.html | 22 ++++++++++++++++++++++ tests/test_Marker.html | 23 +++++++++++++++++++++++ 5 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 tests/test_Icon.html create mode 100644 tests/test_Marker.html diff --git a/lib/OpenLayers/Icon.js b/lib/OpenLayers/Icon.js index 185c40a825..c48a72cb04 100644 --- a/lib/OpenLayers/Icon.js +++ b/lib/OpenLayers/Icon.js @@ -7,7 +7,8 @@ OpenLayers.Icon.prototype = { // {OpenLayers.Size}: size of image size:null, - initialize: function() { - + initialize: function(url, size) { + this.size = size; + this.url = url; } } diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 5ff7d166d4..fbd4c75a5d 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -6,8 +6,35 @@ OpenLayers.Marker.prototype = { // latlon: {OpenLayers.LatLon} location of object latlon: null, + + // events + events: null, + + // map + map: null, + + initialize: function(icon, latlon) { + this.icon = icon; + this.latlon = latlon; + }, - initialize: function() { - - } + draw: function() { + var resolution = this.map.getResolution(); + var extent = this.map.getExtent(); + if (this.latlon.lat > extent.minlat && + this.latlon.lat < extent.maxlat && + this.lonlon.lon > extent.minlon && + this.lonlon.lon < extent.maxlon) { + var pixel = new OpenLayers.Pixel( + resolution * (this.latlon.lon - extent.minlon), + resolution * (extent.maxlat - this.latlon.lat) + ); + // need to account for how much layer has moved... + /* Psuedocode: + div = map.markersDiv; + marker = OpenLayers.Util.createDiv('marker'+rand(), pixel, this.icon.size, null, this.icon.url); + div.appendChild(marker); + */ + } + } } diff --git a/tests/list-tests.html b/tests/list-tests.html index cb0882209b..e828a5fa0a 100644 --- a/tests/list-tests.html +++ b/tests/list-tests.html @@ -1,6 +1,8 @@