[ka-Map-users] Re: Zoom tool

Wei Yang, Ng - Wayne wayne at datalinktech.com.au
Thu May 18 01:32:38 EDT 2006


Hi Paul,
The kaZoomOnClick tool has been written. I also noticed a slight 
switchMode problem in startUp.js. Omitting either the query or pan tool 
will cause the code to break. This has been fixed as well. Just look for 
my name in startUp.js
I have written the new zoom tool in a separate file (kaZoomOnClick.js) 
to avoid confusion. Your sample code uses this.startx and this.starty to 
get pixel coordinates. For some unknown reason, I get null values for 
the two variables. (my query tool isn't working right) Therefore I 
extracted x and y from e.pageX and e.pageY which I believe is safer but 
lengthier.
I am sending the files to you and I will try to find the cause of the 
error in kaQuery.js

Cheers,
Wayne

Paul Spencer wrote:
> Wayne,
>
> you are correct, there is no tool to zoom at the point of click. It 
> would be relatively straightforward to accomplish this with a subclass 
> of the query tool. Here's a sample (untested of course ;))
>
> KAMAP_ZOOMIN = 0;
> KAMAP_ZOOMOUT = 1;
>
> function kaZoomOnClick( oKaMap, type ) {
> kaQuery.apply( this, [oKaMap, KAMAP_POINT_QUERY] );
> this.name = 'kaZoomOnClick';
> this.cursor = 'auto';
> this.type = type;
>
> for (var p in kaQuery.prototype) {
> if (!kaZoomOnClick.prototype[p])
> kaZoomOnClick.prototype[p]= kaQuery.prototype[p];
> }
> };
>
> kaQuery.prototype.onmouseup = function(e) {
> var gp = this.kaMap.pixToGeo( -this.startx, -this.starty );
> var map = this.kaMap.getCurrentMap();
> var scales = this.kaMap.getScales();
> var newScale = map.currentScale;
> if (this.type == KAMAP_ZOOMIN && newScale < scales.length - 1) {
> newScale ++;
> } else if (this.type == KAMAP_ZOOMOUT && newScale > 0) {
> newScale --;
> }
> this.kaMap.zoomTo(gp[0],gp[1], scales[newScale]);
> return false;
> };
>
> Cheers
>
> Paul
>
> On 17-May-06, at 2:28 AM, Wei Yang, Ng - Wayne wrote:
>
>> Hi Paul,
>> I was asked to create a zoom tool that allows me to click any where 
>> on the map and either zoom in on the location or zoom out of it. Is 
>> there such a tool yet? From my understanding there is only the query 
>> and pan tool.
>>
>> Cheers,
>> Wayne
>
> +-----------------------------------------------------------------+
> |Paul Spencer pspencer at dmsolutions.ca |
> +-----------------------------------------------------------------+
> |Applications & Software Development |
> |DM Solutions Group Inc http://www.dmsolutions.ca/|
> +-----------------------------------------------------------------+
>
>
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: kaZoomOnClick.js
Type: text/x-javascript
Size: 3297 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/ka-map-users/attachments/20060518/0d5759e4/kaZoomOnClick.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: startUp.js
Type: text/x-javascript
Size: 16497 bytes
Desc: not available
Url : http://lists.maptools.org/pipermail/ka-map-users/attachments/20060518/0d5759e4/startUp.bin


More information about the ka-Map-users mailing list