[ka-Map-users] Zoom To Layer

Paul Spencer pspencer at dmsolutions.ca
Thu Sep 14 05:04:19 EDT 2006


ah.  That's a different problem entirely :)  Sounds like you have a  
good solution.

Paul

On 13-Sep-06, at 11:20 AM, Wagner, Jeffrey S. ((DMS/CISD)) wrote:

> I started by using init.php to set the layer extents.  However, my
> layers are dynamic and re-drawn every minute.  Rather than updating  
> the
> extents when the layer changes, I used an AJAX call to get the extents
> from XML whenever the user clicks on "zoom".  Then a call to
> zoomTo(x,y,scale) is called. I did not define maxscale in my map file,
> perhaps this is why $oLayer->maxscale didn't work for me.  As a  
> hack, I
> get the scale from the config.php file.
>
>   if ($oLayer->getMetaData( "queryable" ) != "") {
>             $rect = $oLayer->getExtent();
>             $cx = ($rect->minx + $rect->maxx)/2;
> 		$cy = ($rect->miny + $rect->maxy)/2;
> 		
> 		//oLayer->maxscale didn't work for me
> 		$maxscale=
> $aszMapFile['scales'][count($aszMapFile['scales'])-1];
> $layer = "<layer>";
> 		$layer.="<name>".$oLayer->name."</name>";
> 		$layer.="<x>".$cx."</x>";
> 		$layer.="<y>".$cy."</y>";
> 		$layer.="<maxscale>".$maxscale."</maxscale>";
> 		$layer.="</layer>";
>         }
> -----Original Message-----
> From: Paul Spencer [mailto:pspencer at dmsolutions.ca]
> Sent: Wednesday, September 13, 2006 12:37 AM
> To: Wagner, Jeffrey S. (DMS/CISD)
> Cc: Ryan Ollerenshaw; Lucian Bancescu; ka-map-users at lists.maptools.org
> Subject: Re: [ka-Map-users] Zoom To Layer
>
> One thing we could do is add metadata to each layer in a mapfile that
> would define the extent of the layer.  Perhaps using the max_extents
> metadata on each layer?
>
> If the $oLayer->getExtent() actually works, then we could do this in
> init.php when we are reading each map file anyway, although I expect
> this would seriously slow down initialization in some cases.
>
> Using either mechanism, the layer extents could then be passed to
> kaMap in the init.php output.  The layer extents would be stored in
> each of the _layer objects and then it would be trivial to have a
> zoom to layer function in the legend or via some custom scripting.
>
> Patches to implement this would be appreciated :)
>
> Cheers
>
> Paul
>
> On 12-Sep-06, at 1:41 PM, Wagner, Jeffrey S. ((DMS/CISD)) wrote:
>
>> I used MapScript to get the extent: $rect = $oLayer->getExtent();
>> I don't think there is a setExtent function....
>>
>> -----Original Message-----
>> From: ka-map-users-bounces at lists.maptools.org
>> [mailto:ka-map-users-bounces at lists.maptools.org] On Behalf Of Ryan
>> Ollerenshaw
>> Sent: Tuesday, September 12, 2006 7:57 AM
>> To: Lucian Bancescu
>> Cc: ka-map-users at lists.maptools.org
>> Subject: Re: [ka-Map-users] Zoom To Layer
>>
>> Lucian Bancescu wrote:
>>> A pretty straightforward way to obtain the extent of a layer is  
>>> using
>>> ogrinfo, which comes with gdal-ogr tool.
>>> A possible usage:
>>> /
>>> ogrinfo /path/to/shapefiles  layername | grep Extent
>>> /
>>
>> Can you provide the MapScript to add to a layer so each layer has
>> it own
>>
>> extent?
>> _______________________________________________
>> ka-Map-users mailing list
>> ka-Map-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/ka-map-users
>>
>> _______________________________________________
>> 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/|
> +-----------------------------------------------------------------+
>
>
>
>

+-----------------------------------------------------------------+
|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