[mapserver-users] UTFGrid and Cluster, feature distinction: 0, single or clustered
Alexandre Dubé
adube at mapgears.com
Fri Jan 24 07:31:57 PST 2014
Alright! I found a workaround using OpenLayers only. I also noticed
that I made a wrong statement earlier. Let me correct.
In the grid, both the non-clustered AND clustered features are
correctly returned. It's in the 'data' object that only the
non-clustered features are returned, which is fine by me.
That being said, we know that the space character is always used to
represent nothing. Knowing that, I added an additional information to
the callback method that normally returns the id of the feature and the
attributes we had defined in the UTFDATA. I added the index of the
character. If it's 0, the user clicked on nothing. If it's anything
else, it's a single feature if the id is set (since it exists in the
data and was correctly returned) else (when there's no id), it's a cluster.
I'm fine with using this solution, but if there was a way to
accomplish that otherwise, i.e. using MapServer settings, please let me
know.
Regards,
Alexandre
On 14-01-24 09:55 AM, Alexandre Dubé wrote:
> Hi,
>
> I just noticed that when using Clusters, only the non-clustered
> features (singles) are returned in the grid, so clicking on a cluster
> is like clicking on nothing. That explains the behavior I get.
>
> I'll continue to look for a solution.
>
> Alexandre
>
>
> On 14-01-24 09:21 AM, Alexandre Dubé wrote:
>> Hello MapServer community,
>>
>> I'm using the new UTFGrid [1] feature in MapServer in addition with
>> Clusters [2] in an OpenLayers mapping application. I'm trying to
>> implement the following feature: when the user clicks on a single
>> point, a popup gets shown (this works already) and when he/she clicks
>> on a clustered feature, then it must show different popup, without
>> any info about the features inside, nor the extent of the features,
>> but containing a simple link to invite the user to zoom in more.
>>
>> So basically, I'm looking for a way for the returned utfgrid data
>> to know if the clicked element on the map is either: a single
>> feature, a clustered feature or nothing at all. I thought I was
>> close to a solution, but it didn't work as I expected. I thought of
>> using the FeatureCount inside the UTFDATA and then use the value
>> returned to determine the correct type:
>>
>> UTFDATA '{"c":[Cluster:FeatureCount]}'
>>
>> But the utf data only returns 2 values: 1 and 2. It returns 1 when
>> it's a single feature, else 2 whenever it's a clustered feature
>> (regardless of the actual real feature count) and it also returns 2
>> when the user clicks on no feature at all. I'm not sure if my
>> approach is a correct one, though...
>>
>> Does someone have any idea how I could accomplish what I'm trying
>> to do ? I'm using a trunk version of MapServer I haven't updated for
>> a couple months.
>>
>> Many thanks,
>>
>> Alexandre
>>
>> [1] http://mapserver.org/development/rfc/ms-rfc-93.html
>> [2] http://mapserver.org/mapfile/cluster.html
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list