[ka-Map-users] Adding a marker (image) functionality to KaMap

Paul Spencer pspencer at dmsolutions.ca
Tue May 9 14:32:52 EDT 2006


I would imagine that the offsets were put there to move the image so  
that the bottom center was at the point you wanted to indicate,  
rather than the top left.

The preferred way to do this is to use

this.img.xOffset = -7.5; //actually this needs to be an int
this.img.yOffset = -27;
this.kaMap.addObjectGeo(this.canvas, x, y, this.img);

where x and y are in geographic coordinates.  I don't encourage the  
use of addObjectPix as it is tricky to get the math right for  
calculating the coordinates in pixel space.

However, if it worked at one time and you haven't changed anything,  
it should still work so you must have updated or changed something.   
Just not sure what :)

There haven't really been changes in the related code in the last  
month so I doubt updating would fix the problem (but its always worth  
a shot :))



On 9-May-06, at 2:15 PM, Clark Endrizzi wrote:

> I had this working previously with some older cvs stuff.  Basically  
> I have a custom tool that when you click on a the map it puts a  
> marker there.
> My implementation is very simple.
> On the tool initialization:
>     // marker
>       this.canvas = this.kaMap.createDrawingCanvas(500); //zindex=500
>       this.img = document.createElement('img');
>       this.img.src = 'images/mapping/Marker.png';
> Then I have a function on the tool that does this:
> this.kaMap.addObjectPix(this.canvas, (pixPosition[0] - 7.5),  
> (pixPosition[1] -27), this.img );
> I can't remember why I had the - 7.5 and -27 offsets.
> Should this not work?  Has anything changed.  I should say my  
> version I'm using now is over a month old so may I should upgrade  
> to a new cvs version if there have been fixes in this area.  I have  
> tried AddObjectGeo too to pinpoint a specific place.  It appears  
> that the canvas or something just isn't showing up...
> Lastly the image is there so that does't appear to be the issue.
> I hope this makes sense.  Thanks much,
> -- 
> Clark Endrizzi
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users

|Paul Spencer                           pspencer at dmsolutions.ca   |
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|

More information about the ka-Map-users mailing list