0

I made a module retrieving data with geodata. The import feature allows to create a file in geojson. So, i'd like to display the points and the data without using Views, only openlayers module. I saw the layer example provided with the module : Example GeoJSON, "Picture This", displaying a marker with the given raw geojson data provided. In the Layer section, I tried to use the URL field instead of the raw data field to provide a link to my datafile, but when i use it on a map, only the last point is displayed.

I saw that in the example :

  {
    "type": "Feature",
    "properties": {
      "name": "Picture This",
      "description": "Outside of the North Carolina Museum of Art."
    },
    "geometry": {
      "type": "Point",
      "coordinates": [
        -78.702798,
        35.809411
      ]
    },
    "crs": {
      "type": "name",
      "properties": {
          "name": "urn:ogc:def:crs:OGC:1.3:CRS84"
      }
    }
  }

but the "regular"geojson is a collection of such features :

{ "type": "FeatureCollection", "features": [
      {
        "type": "Feature",
        "properties": {"name": "point1", "description": "desc of 1"},
        "geometry": {"type": "Point", "coordinates": [-78, 35]
        }
      },
      {
        "type": "Feature",
        "properties": {"name": "point2", "description": "desc of 2"},
        "geometry": {"type": "Point", "coordinates": [-79, 34]
        }
      }
]}

So, since i have more than 1 point i used the second version, and i only get the last point showing when i use this overlay on a map.

Is there something special to do to display several point or shapes (from a layer) using that technique : i'd like to avoid using Views or any other plugins for this.

I've read https://www.drupal.org/node/1481374 and other generic openlayer Drupal 7 tutorials, but i haven't found any help for this kind of problem. Thanks in advance

0

Finally, i found out that the problems (only the last point and that point wasn't at the right place) had nothing to do with my geojson file : i created a new layer and by default it had projection EPSG:3857, but i needed a projection with GPS coordinates => EPSG:4326 see this . With that change, every point is now displayed. I guess with the wrong projection, all the points where somehow stacked, and then only the last one was displayable.

In Openlayer > Layers

  • Use Projection EPSG:4326 (instead of EPSG:3857)

In Openlayer > Map Use

  • Map Projection EPSG:3857 (Default)
  • Display Projection EPSG:4326(Default)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.