[OpenLayers-Users] Cluster Strategy and Google Layer

Salvaro asufsc at gmail.com
Tue Nov 18 05:14:54 EST 2008


Thanks for the answers!

I fixed the problem with Google Maps putting all configs (extent,
resolution,projection..) in the MapOptions (so, vectorLayer got them too).
But by this way I can use only GMaps and have to find another way to use WMS
togheter.

At least, it worked.

Thanks!


GordonHo wrote:
> 
> hi,
> 
> i had a similiar problem though got it solved.
> here the configuration i use:
> 
> 		var options = {
> 	                projection: new OpenLayers.Projection("EPSG:900913"),
> 	                displayProjection: new
> OpenLayers.Projection("EPSG:4326"),
> 	                units: "m",
> 					panMethod: OpenLayers.Easing.Quad.easeOut,
> 	                numZoomLevels: 12,
> 	                minZoomLevel: 1,
> 	                maxResolution: 156543.0339,
> 	                maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
> 	                                                 20037508, 20037508.34),
> 			    controls:[
> 						    new OpenLayers.Control.Navigation({'zoomWheelEnabled': false}),
> 						    new OpenLayers.Control.MousePosition(),
> 						    new OpenLayers.Control.PanZoomBar({zoomStopHeight:12,
> zoomWorldIcon:true}),
> 					    ]
> 	            };
> 	            
> 	var layerPhy = new OpenLayers.Layer.Google("Terrain",
> {type:G_PHYSICAL_MAP, wrapDateLine:true, 'sphericalMercator': true});
> 
> 
> 	var markers = new OpenLayers.Layer.Vector("Markers", {
>                     strategies: [
>                         bbox ,
>                         new OpenLayers.Strategy.Cluster()
>                     ],
>                     protocol: new OpenLayers.Protocol.HTTP({
>                         url: "/AJAX/GeoData.php",
>                         params: {
>                         },
>                         format: new OpenLayers.Format.Text({
> 							internalProjection: map.getProjectionObject(),
> 							externalProjection: map.displayProjection
> 							})	
>                     }),
>                     styleMap: new OpenLayers.StyleMap({
>                         "default": style,
>                         "select": {
>                             fillColor: "#808080",
>                             strokeColor: "#000000"
>                         }
>                     })
>                 });
> 
> 
> important were:
>  - displayprojection and projection in the map constructor
>  - spheciralmercator on google map
>  - internal / external projection on the format
> 
> hope this helps... 
> 
> cheers, gordon
> 
> 
> mippon wrote:
>> 
>> 
>> Have a look at this thread, 
>> 
>> http://www.nabble.com/forum/ViewPost.jtp?post=20371907&framed=y
>> 
>> 
>> Salvaro wrote:
>>> 
>>> 
>>> Hey,
>>> 
>>> I just added in Map Options the projection EPSG:900913.
>>> The Google layer is with the same parameters, and Vector Layer in
>>> options
>>> only receive an array with Fixed and Cluster Strategies.
>>> 
>>> MapOptions: numZoomLeves=19, projection=EPSG:900913,
>>> displayProjection=EPSG:4326 and the controls.
>>> Vector Layer: strategies=a strategies array.
>>> Google: projection=EPSG:900913, type=GMAPS, Bounds=-20037508.34,
>>> -20037508.34,20037508.34, 20037508.34,
>>> maxResolution=156543.0339F,sphericalMercator=true, units=m.
>>> 
>>> The problem only happens with Google Layer (as you can see above), in
>>> WMS
>>> (EPSG:4326) it works well.
>>> 
>>> Have no idea about what is happening.
>>> 
>>> Thanks, Eric!
>>> 
>>> 
>>> Eric Lemoine wrote:
>>>> 
>>>> Hi Salvaro. Please show us your new code. Eric
>>>> 
>>>> 2008/11/3, Salvaro <asufsc at gmail.com>:
>>>>>
>>>>> Hi Eric, thanks for your answer!
>>>>>
>>>>> I set in the map this projection, but the problem still continues.
>>>>> If the points are in the correct coordinates (reprojection), the
>>>>> cluster
>>>>> strategy is ignored by the layer.
>>>>> Else if the points are in the incorrect coordinates the cluster
>>>>> aparently
>>>>> works, but obviously all the points are in the center of the map.
>>>>>
>>>>> I tried much things, but really have no idea about what it can be =/.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> Using WMS in EPSG:4326 all works well.
>>>>>
>>>>>
>>>>> Eric Lemoine wrote:
>>>>>>
>>>>>> Hi. The EPSG:900913 projection should be set in the map options. In
>>>>>> this way your vector layer is also a 900913-projected layer. If your
>>>>>> vector points are expressed in 4326 you have to have them
>>>>>> re-projected
>>>>>> before the're added to the layer. Eric
>>>>>>
>>>>>> 2008/10/31, Salvaro <asufsc at gmail.com>:
>>>>>>>
>>>>>>> I'm using a Vector Layer with Cluster Strategy (and Fixed)
>>>>>>> overlaying
>>>>>>> a
>>>>>>> WMS
>>>>>>> (EPSG:4326) and a Google Layer (EPSG:900913).
>>>>>>>
>>>>>>> In the WMS layer the strategy works perfectly. But in Google Layer,
>>>>>>> the
>>>>>>> layer apparently ignores the Strategy.
>>>>>>>
>>>>>>> Testing I saw a "strange" thing, when I use the points in EPSG:4326
>>>>>>> coordinates in the Google Layer and all points are in the centre of
>>>>>>> the
>>>>>>> map,
>>>>>>> looking the opacity is possible to see the points being "clustered".
>>>>>>> But
>>>>>>> when I try to reproject them or just set different coordinates of
>>>>>>> the
>>>>>>> google
>>>>>>> projection, the layer ignores the cluster.
>>>>>>>
>>>>>>> The points with correct projection:
>>>>>>> http://img225.imageshack.us/my.php?image=correctprojectionyx8.jpg
>>>>>>>
>>>>>>> And with the incorrect projection:
>>>>>>> http://img404.imageshack.us/my.php?image=wrongprojectiontk6.jpg
>>>>>>> http://img505.imageshack.us/my.php?image=wrongprojection2ty8.jpg
>>>>>>>
>>>>>>> I'm using in the Map these attributes: numZoomLevels=19,
>>>>>>> displayProjection=EPSG:4326 and the controls.
>>>>>>> In the layer: type=GMAPS, projection=EPSG:900913,
>>>>>>> maxExtent=-20037508.34,
>>>>>>> -20037508.34, 	20037508.34, 20037508.34, units=m,
>>>>>>> maxResolution=156543.0339F
>>>>>>> and sphericalMercator=true.
>>>>>>>
>>>>>>> The points are being added using addFeatures.
>>>>>>>
>>>>>>>
>>>>>>> Anyone have an idea about what it can be and how can I do the
>>>>>>> cluster
>>>>>>> works
>>>>>>> with the Google Layer?
>>>>>>>
>>>>>>> Thanks!
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> http://n2.nabble.com/Cluster-Strategy-and-Google-Layer-tp1402961p1402961.html
>>>>>>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> Users mailing list
>>>>>>> Users at openlayers.org
>>>>>>> http://openlayers.org/mailman/listinfo/users
>>>>>>>
>>>>>> _______________________________________________
>>>>>> Users mailing list
>>>>>> Users at openlayers.org
>>>>>> http://openlayers.org/mailman/listinfo/users
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://n2.nabble.com/Cluster-Strategy-and-Google-Layer-tp1402961p1448871.html
>>>>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>>>>
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at openlayers.org
>>>>> http://openlayers.org/mailman/listinfo/users
>>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at openlayers.org
>>>> http://openlayers.org/mailman/listinfo/users
>>>> 
>>>> 
>>> 
>>> -- 
>>> View this message in context:
>>> http://n2.nabble.com/Cluster-Strategy-and-Google-Layer-tp1402961p1453785.html
>>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>>> 
>>> _______________________________________________
>>> Users mailing list
>>> Users at openlayers.org
>>> http://openlayers.org/mailman/listinfo/users
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Cluster-Strategy-and-Google-Layer-tp20265419p20541794.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>> 
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>> 
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/Cluster-Strategy-and-Google-Layer-tp1402961p1513723.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list