[OpenLayers-Users] Non-terrestrial datum [proj4] and ScaleLine
Andreas Hocevar
ahocevar at opengeo.org
Thu Jul 11 04:57:30 PDT 2013
Your map configuration is very incomplete. OpenLayers does not pick up
things like units from proj4js for the map configuration, so you also have
to set units on the map. You also need to set maxExtent and maxResolution
on the map, otherwise you will get defaults from WGS84. Finally, if your
projection's units are meters, you also need to set your layer maxExtent in
meter coordinates.
Andreas.
On Thu, Jul 11, 2013 at 10:48 AM, a.lucas at geolnet.net
<a.lucas at geolnet.net>wrote:
> Hello,
>
> here is the full code I wrote.
> I have some images for the background and a vector layer I can display
> over the base map.
>
>
> Thanks for any help.
>
> <script type="text/javascript">
>
> Proj4js.defs["PLANETB"] = "+proj=eqc +a=4500000 +b=4500000 +units=m
> +no_defs";
>
> var map, vectors, formats;
> var graticuleCtl1, graticuleCtl2;
>
>
> function init(){
>
> map = new OpenLayers.Map('map', { controls: [ new
> OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar(),new
> OpenLayers.Control.ScaleLine({bottomOutUnits: '',geodesic: true}), new
> OpenLayers.Control.MousePosition(), new OpenLayers.Control.Graticule()
> ],
> projection: new OpenLayers.Projection("PLANETB")
> });
> var ls = new OpenLayers.Control.LayerSwitcher() map.addControl(ls);ls.maximizeControl();
> var iss = new OpenLayers.Layer.Image( 'ISS (Base 3)', 'Data/ISS.gif', new
> OpenLayers.Bounds(-180, -90, 180, 90), new OpenLayers.Size(800, 400),{numZoomLevels: 4});
> var topo = new OpenLayers.Layer.Image( 'Topography (Splined)',
> 'Data/spline.png', new OpenLayers.Bounds(-180, -90, 180, 90), new
> OpenLayers.Size(800, 400), {numZoomLevels:1} );
>
>
> var blank = new OpenLayers.Layer.Image( 'Blank (No Base Map)', '', new
> OpenLayers.Bounds(-180, -90, 180, 90), new OpenLayers.Size(800, 400),{numZoomLevels: 4});
>
>
>
>
> var blue_unit = new OpenLayers.Layer.Vector("Blue Unit", { protocol: new
> OpenLayers.Protocol.HTTP({ url: "Data/blue_unit.gml", format: new
> OpenLayers.Format.GML() }), strategies: [new OpenLayers.Strategy.Fixed()],visibility: true,//wrapDateLine: true,style: {fillColor: "#0066cc",fillOpacity:0.4 , strokeWidth: 1, strokeColor:
> "#0066cc", strokeOpacity: 1 }, projection: map.displayProjection, });
>
>
>
> map.addLayers([blank, topo,iss,vims,sar,rad,dark_unit,blue_unit,dunes]);
>
> map.zoomToMaxExtent();
> var options = { hover: true, onSelect: serialize }; updateFormats();
> map.setCenter(new OpenLayers.LonLat(0, 0), 1); }
>
>
>
>
>
> </script>
>
>
>
>
> On Mon, Jul 8, 2013 at 3:40 PM, Andreas Hocevar <ahocevar at opengeo.org>wrote:
>
>> Hey,
>>
>> are you sure that your map actually uses the 'PLANETB' projection? Show a
>> bit more code, especially which layers you add, or preferably point us to a
>> fully configured example. Note that the base layer's projection - if
>> specified - overrides the map projection.
>>
>> Andreas.
>>
>>
>> On Mon, Jul 8, 2013 at 2:51 PM, a.lucas at geolnet.net <a.lucas at geolnet.net>wrote:
>>
>>> Hello Folks,
>>>
>>> I already asked but got no reply, so I repost my question, sorry for
>>> spamming you on that.
>>>
>>>
>>>
>>>
>>> I intend to use OpenLayers for an educational project dealing with
>>> planetary data.
>>> I tried to get an accurate scale bar (i.e., ScaleLine object) from a
>>> custom projection but it seems that ScaleLine does not understand
>>> non-terrestrial sphere/ellipsoid.
>>>
>>> Here is what I have done:
>>>
>>> I first call proj4js:
>>> <script src="
>>> http://svn.osgeo.org/metacrs/proj4js/trunk/lib/proj4js-compressed.js
>>> "></script>
>>> then OpenLayers
>>>
>>> and in a javascript sequence I do this:
>>>
>>> Proj4js.defs["PLANETB"] = "+proj=eqc +a=4500000 +b=4500000 +units=m
>>> +no_defs";
>>>
>>> function init(){
>>>
>>> map = new OpenLayers.Map('map', {
>>> controls: [
>>> new OpenLayers.Control.Navigation(),
>>> new OpenLayers.Control.PanZoomBar(),
>>> new OpenLayers.Control.ScaleLine({bottomOutUnits:
>>> '',geodesic: true}),
>>> new OpenLayers.Control.MousePosition(),
>>> new OpenLayers.Control.Graticule()
>>> ],
>>> projection: new OpenLayers.Projection("PLANETB")
>>> });
>>>
>>> Unfortunately, when displaying the page, the scale bar is totally wrong.
>>> I played with different values of "a" and "b", ScaleLine does NOT take into
>>> account these values. The Proj4 syntax seems correct as it works smoothly
>>> under QGIS for instance. For me, OpenLayers just does not understand
>>> correctly proj4 projection.
>>>
>>> Any idea if OpenLayer can really understand proj4 syntax? and if not,
>>> how can I contribute (i.e., where, which files?) in order to get this right?
>>>
>>>
>>> thank you for any feedback/ideas
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>>>
>>
>>
>> --
>> Andreas Hocevar
>> OpenGeo - http://opengeo.org/
>> Expert service straight from the developers.
>>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130711/2d644717/attachment.html>
More information about the Users
mailing list