[OpenLayers-Users] (no subject)

Giuseppe Falcone falcone.giuseppe at gmail.com
Tue Jan 14 07:11:50 PST 2014


Hi all,

I still have problems with map.

The feature of the http layer appears in wrong position, or rather, is the
base layer position wrong according the coordinates visible on the map.

This is a test file:

<!DOCTYPE html>
<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
        <title>OpenLayers Vector Behavior Example</title>
        <link rel="stylesheet" href="style.css" type="text/css">
        <script src="/js/ol/OpenLayers.js"></script>
        <script type="text/javascript">
            var map;

            function init() {
                map = new OpenLayers.Map('map',{
                  'projection':new OpenLayers.Projection("EPSG:32633"),
                  'displayProjection':new
OpenLayers.Projection("EPSG:32633")
                });

                map.addControl(
                  new OpenLayers.Control.MousePosition({
                    prefix: 'coordinates: ',
                    separator: ' , ',
                    numDigits: 2
                  })
                );

                var osmLayer = new OpenLayers.Layer.OSM("OSM", "
http://tile.openstreetmap.org/${z}/${x}/${y}.png");

                var httpLayer = new OpenLayers.Layer.Vector("HTTP", {
                    strategies: [
                      new OpenLayers.Strategy.BBOX(),
                      new OpenLayers.Strategy.Cluster({threshold:2})
                    ],
                    protocol: new OpenLayers.Protocol.HTTP({
                      url:  "/lwa/aib/feature/firealert",
                      format: new OpenLayers.Format.GeoJSON()
                    }),
                    'projection':new OpenLayers.Projection("EPSG:32633")
                });

                var fromProjection = new OpenLayers.Projection("EPSG:4326");
                var toProjection   = new
OpenLayers.Projection("EPSG:900913");

                map.addControl(new OpenLayers.Control.PanZoomBar());
                map.addLayer(osmLayer);
                map.setBaseLayer(osmLayer);

                map.setOptions({projection:map.getProjectionObject()});
                map.setCenter(new OpenLayers.LonLat(14.84,
40.8).transform(fromProjection, toProjection), 8);
                map.addLayer(httpLayer);
            }
        </script>
    </head>
    <body onload="init()">
      <h1 id="title">Vector Behavior Example</h1>
      <div id="tags">
        wfs, vector
      </div>
      <p id="shortdesc">
        Uses a BBOX strategy, WFS protocol, and JSON format.
      </p>
      <div id="map" class="smallmap"></div>
    </body>
</html>



/lwa/aib/feature/firealert is this geoJSON

{
  "layerId": "LAYER_ID",
  "id": "idFire",
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "id": "5260ff4ef169d6bc06000881",
        "graphicXOffset": -12,
        "graphicWidth": 24,
        "graphicYOffset": -12,
        "clickMsg": "FAFeatureClick",
        "externalGraphic": "core/giallo.png",
        "hoverTooltip": "CE1310000001",
        "graphicHeight": 24
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          432382.780106,
          4581712.6739
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "id": "5260ff4ef169d6bc06000882",
        "graphicXOffset": -12,
        "graphicWidth": 24,
        "graphicYOffset": -12,
        "clickMsg": "FAFeatureClick",
        "externalGraphic": "core/rosso.png",
        "hoverTooltip": "CE1310000002",
        "graphicHeight": 24
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          433482.780106,
          4582712.6739
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "id": "52610c1ef169d6bc0600088b",
        "graphicXOffset": -12,
        "graphicWidth": 24,
        "graphicYOffset": -12,
        "clickMsg": "FAFeatureClick",
        "externalGraphic": "core/verde.png",
        "hoverTooltip": "CE1310000003",
        "graphicHeight": 24
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          445557,
          4532769
        ]
      }
    }
  ]
}



2014/1/14 Hugo <hfpmartins at gmail.com>

> Hi Giuseppe,
>
> If you wish to show those coordinates you can configure the MousePosition
> control to use that projection (displayProjection config option) while
> still having the map projection set as EPSG:3857.
>
> Cheers,
>
>
> On Tue, Jan 14, 2014 at 10:53 AM, Giuseppe Falcone <
> falcone.giuseppe at gmail.com> wrote:
>
>> Hi Hugo,
>>
>> thanks for the response. I need to use EPSG:32633 because this coordinate
>> are shown.
>>
>>
>> 2014/1/14 Hugo <hfpmartins at gmail.com>
>>
>>> Hi Giuseppe,
>>>
>>> If you wish to use OSM and other available layers using sperical
>>> mercator (google, bing, ...) you will need to define your map projection as
>>> EPSG:3857 and reproject all your remaining layers.
>>>
>>> Hope this helps,
>>>
>>>
>>> On Tue, Jan 14, 2014 at 10:33 AM, Giuseppe Falcone <
>>> falcone.giuseppe at gmail.com> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have a map with base layer with projection EPSG:32633. Others layer
>>>> have same projection and also OpenLayers.Map object.
>>>>
>>>> When I add OSM or Google base layer, that have different projection,
>>>> the map center and zoom are completely wrong (I see all planisphere....).
>>>>
>>>> Anyone has any idea?
>>>>
>>>> Thanks a lot.
>>>>
>>>> Giuseppe
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>>
>>>
>>>
>>>
>>> --
>>> Hugo Martins
>>>
>>
>>
>
>
> --
> Hugo Martins
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140114/e65998e5/attachment-0001.html>


More information about the Users mailing list