i only used this funciton because i didn't notice you could accomplish the same (over all canvases) by sending no args to removeObject. a simple change would be to allow the second arg to the existing removeObject() specify a canvas....
<br>-b<br><br><br><br><br><div><span class="gmail_quote">On 3/22/06, <b class="gmail_sendername">Paul Spencer</b> <<a href="mailto:pspencer@dmsolutions.ca">pspencer@dmsolutions.ca</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
not sure if I commented on this before, but it should be noted that a<br>function like this already exists (removeObject) but it doesn't allow<br>you to clear all the overlays on a single canvas, it only allows<br>removing individual overlays or all overlays.
<br><br>Is there interest in adding this function? I don't see a need for it<br>as I usually manage the overlays separately from kaMap and thus have<br>have a reference to the things that need to be removed.<br><br>Cheers
<br><br>Paul<br><br>On 5-Mar-06, at 12:56 PM, Brent Pedersen wrote:<br><br>> hi chris, another utility function you'll use:<br>><br>> kaMap.prototype.removeOverlays = function(canvas){<br>> len = this.aObjects.length
;<br>> for(i=0;i<br>> var item = this.aObjects[i];<br>> if(item.canvas == canvas){<br>> canvas.removeChild(item);<br>> item.canvas = null;<br>> item = null;<br>> this.aObjects.splice(i--,1);<br>> len =
this.aObjects.length;<br>> }<br>> }<br>> }<br>><br>> then call myKaMap.removeOverlays(myCanvas) at the start of<br>> drawMarkers. because otehrwise, you jsut keep adding new markers<br>> without getting rid of the old ones. and it will get rid of them
<br>> when you're not at the scale you want.<br>><br>> also as you have it now, you're creating a new canvas every time<br>> drawMarkers is called. probably bad.<br>><br>> i'm not sure about the memory leakage of any of this...
<br>> -b<br>><br>><br>><br>><br>> On 3/5/06, Base Bloc < <a href="mailto:chris@basebloc.com">chris@basebloc.com</a>> wrote:<br>> Hi Guys,<br>><br>><br>> I'm still plugging away to get some workable functions together to
<br>> draw markers with tool-tips and it's hard work as I'm experienced<br>> with PHP but not so hot on JavaScript and DOM so am making all the<br>> usual mistakes but getting there slowly. I now have a system in
<br>> place that at a curtain scale places markers within an extended<br>> extent of the visible map tiles using HttpRequest. All is working<br>> fine and I currently have the system getting markers from a<br>> database to place markers on the map at the required scale
<br>> (1:300000), then adding more markers as the map is panned.<br>><br>><br>> The problem I'm encountering now is that although the function is<br>> working correctly as in it won't add markers+tool-tips until the
<br>> map is zoomed to 1:300000 when the map is zoomed back out above<br>> 1:300000 the markers previously called all remain on screen and as<br>> there are over 7000 points you can imagine what this looks like at
<br>> 1:4000000.<br>><br>><br>> Is there a simple way to clear all of the markers created by<br>> addObjectGeo when the map is zoomed out past a curtain scale or<br>> better yet add an event related to myKaMap.getCurrentScale
() so<br>> they are only displayed when the scale in greater than X?<br>><br>><br>> Here are the functions I'm using at present:<br>><br>><br>> //creates separate image for each marker<br>><br>> function create_marker (img_id, var_1, lat, lon)
<br>><br>> {<br>><br>><br>> document[img_id] = document.createElement( 'img' );<br>><br>> document[img_id].src = 'images/kamap.gif';<br>><br>><br>> var bname =
navigator.appName;<br>><br>> if (bname == "Microsoft Internet Explorer")<br>><br>> {<br>><br>> document[img_id].attachEvent<br>> ("onmouseover",tool_tip)
<br>><br>> document[img_id].attachEvent<br>> ("onmouseout",tool_tip_out)<br>><br>> document[img_id].attachEvent<br>> ("onclick",page_link)
<br>><br>> }<br>><br>> else<br>><br>> {<br>><br>> document[img_id].addEventListener<br>> ("mouseover",tool_tip,false)
<br>><br>> document[img_id].addEventListener<br>> ("mouseout",tool_tip_out,false)<br>><br>> document[img_id].addEventListener<br>> ("click",page_link,false)
<br>><br>> }<br>><br>><br>> //Sends content and format<br>> options to tool-tip<br>><br>> function tool_tip(){
<br>><br>><br>> var test_var = var_1;<br>><br>> var text = "My name<br>> is " +test_var+ ", and I'm am now understanding JavaScripts";
<br>><br>> overlib(text,<br>> STICKY, MOUSEOFF, CAPTION, 'info')<br>><br>> }<br>><br>><br>> myKaMap.addObjectGeo
( myCanvas, lat, lon, document[img_id] );<br>><br>><br>> }<br>><br>><br>> function drawMarkers(){<br>><br>> Big_Extents = myKaMap.getGeoExpandedExtents();<br>><br>> myCanvas =
myKaMap.createDrawingCanvas( 5000 );<br>><br>><br>> //draw Markers within Big_Extents using kaXMLOverlay or just<br>> addObjectGeo()<br>><br>><br>> var scale = myKaMap.getCurrentScale();
<br>><br>><br>> if (scale <= 200000)<br>><br>> {<br>><br>><br>> //this is where the HttpRequest would normally go, but<br>> I have placed a couple of sample markers to make the script more clear
<br>><br>> create_marker('C02573', 'Box', 511275, 1363860);<br>><br>> create_marker('C02574', 'Pipe', 515736, 1364260);<br>><br>><br>> }<br>><br>><br>> }<br>
><br>><br>> var scale = myKaMap.getCurrentScale();<br>><br>><br>><br>> myKaMap.registerForEvent( KAMAP_SCALE_CHANGED, null,<br>> drawMarkers );<br>><br>> myKaMap.registerForEvent
( KAMAP_EXTENTS_CHANGED, null,<br>> maybeRedraw );<br>><br>> myKaMap.registerForEvent( KAMAP_MAP_INITIALIZED, null,<br>> drawMarkers );<br>><br>><br>> }<br>><br>><br>> Sorry there are a few calls to functions there which I have not
<br>> added above, I didn't want to do a 500 line cut and paste, once I<br>> have it working properly I will post the full code and related<br>> functions.<br>><br>><br>> Any suggestions on a fix to this problem would be appreciated.
<br>><br>><br>> Thanks,<br>><br>><br>> Chris<br>><br>><br>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>><br>> Christopher Brown<br>><br>> Head of Internet Development<br>><br>> Base Bloc Cambodia
<br>><br>> #33, 123, Phnom Penh, Cambodia.<br>><br>> P.O. Box 2086<br>><br>> <a href="http://www.basebloc.com">www.basebloc.com</a><br>><br>> Tel (+885) 12 315 302<br>><br>><br>><br>> _______________________________________________
<br>> ka-Map-users mailing list<br>> <a href="mailto:ka-Map-users@lists.maptools.org">ka-Map-users@lists.maptools.org</a><br>> <a href="http://lists.maptools.org/mailman/listinfo/ka-map-users">http://lists.maptools.org/mailman/listinfo/ka-map-users
</a><br>><br>><br>><br>> _______________________________________________<br>> ka-Map-users mailing list<br>> <a href="mailto:ka-Map-users@lists.maptools.org">ka-Map-users@lists.maptools.org</a><br>> <a href="http://lists.maptools.org/mailman/listinfo/ka-map-users">
http://lists.maptools.org/mailman/listinfo/ka-map-users</a><br><br>+-----------------------------------------------------------------+<br>|Paul Spencer <a href="mailto:pspencer@dmsolutions.ca">pspencer@dmsolutions.ca
</a> |<br>+-----------------------------------------------------------------+<br>|Applications & Software Development |<br>|DM Solutions Group Inc <a href="http://www.dmsolutions.ca/|">
http://www.dmsolutions.ca/|</a><br>+-----------------------------------------------------------------+<br><br><br><br><br></blockquote></div><br>