1

I've installed OpenLayers in Drupal 7 and created a view that pulls geofield data for a "Geography" vocabulary (states, tribes, and U.S. jurisdictions) and shows points on a map that I'm storing on MapBox's server. The map tiles I created in TileMill.

The map displays fine, the points appear in the proper locations, but I can't get the map to center properly -- it appears somewhere off the coast of western Africa. I'm guessing that this is a "projection" problem.

  • TileMill maps are always projected to "Web Mercator" (EPSG:3857)
  • So, for the layer that I've added, I've used layer type "XYZ" and set the "Projection" to "EPSG:3857"
  • In the "Layers & Styles" tab for the map, I've selected "EPSG:3857" for the "Map Projection"
  • I've also set the "Display Projection" to "EPSG:3857"
  • Because I'd like the map to be centered over/near California, I've made the "Centerpoint" in the "Center & Bounds" tab equal to "-122, 33"
  • I've also tried "Zoom to Layer" in the "Behaviors" tab -- but that doesn't seem to work either.

I'm guessing there's something conceptual that I'm missing here -- that there's something about projections that I don't understand, right?

4
  • 1
    sounds like you have found Null Island nullisland.com - try specifing the center of your map in meters instead of degrees
    – Ian Turton
    Commented Mar 17, 2014 at 14:15
  • I tried MickyInTheSky's suggestion "-13268680,4332034" (which would be in meters, right?) but the map won't recenter.
    – beuner
    Commented Mar 17, 2014 at 16:01
  • @twogunz - Converting the coordinate pair used by you (-122 33 - EPSG: 4626) I realized that fall into the Pacific ocean (or as Iant said near "Null Island"). The coordinates "-13268680,4332034" (EPSG:3857) corresponds to a point about 20 km SE from Visalia (CA). Commented Mar 18, 2014 at 7:55
  • I thought "Null Island" was off the coast of Africa? Still, when I use your converted (EPSG:3857) coordinate pair I still can't get the map to recenter properly. Ugh! Thank you for all your help, though! I'll have to try wildintellect's suggestion...
    – beuner
    Commented Mar 18, 2014 at 14:42

2 Answers 2

2

Followup to Micklyn's response: After map intialization do a setCenter, you can also do a reproject on the coordinates to make it easier to read.

map.setCenter(OpenLayers.LonLat(-122,33).transform(
    new OpenLayers.Projection("EPSG:4326"),
        map.getProjectionObject()))

Example at line 138.

1

If you want to use exactly this centerpoint, maybe you have to reproject the coordinate pair "-122,33" (are they in EPSG:4326?) in the EPSG:3857.

You'll get a pair of values ​​similar to "-13268680,4332034"

1
  • Thanks -- I tried "-13268680,4332034" in the "Centerpoint" field for the map in the OpenLayers module, but to no avail.
    – beuner
    Commented Mar 17, 2014 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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