{"id":120,"date":"2009-02-10T12:19:45","date_gmt":"2009-02-10T17:19:45","guid":{"rendered":"http:\/\/thaylin.info\/blog\/?p=120"},"modified":"2009-02-10T22:55:41","modified_gmt":"2009-02-11T03:55:41","slug":"recursive-method-annoyance","status":"publish","type":"post","link":"https:\/\/www.thaylin.com\/blog\/2009\/02\/10\/recursive-method-annoyance\/","title":{"rendered":"Recursive method annoyance"},"content":{"rendered":"<p>So I&#8217;ve been working on incarnations of a mapping application over the last year or so and am rather happy with how it&#8217;s been growing so far but one thing has come to my attention.\u00a0<\/p>\n<p>The map pulls in hotel properties and displays them as markers on the map depending on the x and y values that I get returned back to me via a service I call. Everything is fine for, say, 84, properties. But pulling 159 properties becomes a task for the map to handle. Basically it stems down to the method I&#8217;ve implemented for clustering markers. If a marker is touching another marker it should gather the data from both of the markers, likewise, if that marker is touching a different maker then all 3 have the collection of data from all three. Once a click is done on any one of those markers it then displays all of the markers data that are overlapped.\u00a0<\/p>\n<p>The method I have that does this determines based on an array of items that are touching each other, goes through the array and cancels out if it is in the markers&#8217; neighbors array. Otherwise it loops through that neighbor array and adds itself to the neighbor array.\u00a0<\/p>\n<p>Earlier I said it was fine with 84 but a nightmare with 159, but that&#8217;s not entirely true. It&#8217;s really based on how many items are overlapping each other. So I suppose this would be a issue if there were 84 markers overlapping each other in one big cluster as well.<\/p>\n<p>Here is the code to give you a better idea.<\/p>\n<pre lang=\"actionscript\" line=\"1\" colla=\"+\">\r\npublic function addNeighbor(item:CityOnMap):void\r\n{\r\n\tvar hasItem:Boolean = false;\r\n\tvar i:int = 0;\r\n\tvar itemNeighborsLength:int;\r\n\tvar neighborsArrLength:int = neighbors.length;\r\n\t\r\n\tfor each (var name:CityOnMap in neighbors)\r\n\t{\r\n\t\tif(name == item)hasItem = true;\r\n\t}\r\n\t\r\n\tif(!hasItem)\r\n\t{\r\n\t\tneighbors.push(item)\r\n\t\titemNeighborsLength = item.neighbors.length;\r\n\t\titem.addNeighbor(this);\r\n\t\t\r\n\t\twhile(i<itemNeighborsLength)\r\n\t\t{\r\n\t\t\tCityOnMap(item.neighbors[i]).addNeighbor(this);\r\n\t\t\ti += 1;\r\n\t\t}\r\n\t}\r\n\t\r\n}\r\n<\/pre>\n<p>I'll be doing more research and post an update to this issue I'm having. Hopefully someone can shed some light on a different methodology to use. ugh. I just need another set of eyes...<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I&#8217;ve been working on incarnations of a mapping application over the last year or so and am rather happy with how it&#8217;s been growing so far but one thing has come to my attention.\u00a0 The map pulls in hotel properties and displays them as markers on the map depending on the x and y [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[32,31],"_links":{"self":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/120"}],"collection":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":5,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":125,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/posts\/120\/revisions\/125"}],"wp:attachment":[{"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.thaylin.com\/blog\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}