[OpenLayers-Users] Mapping the globe with OpenLayers
Jani Patokallio
jpatokal at iki.fi
Mon Jul 21 15:52:26 EDT 2008
Greetings,
New to OpenLayers and loving it -- but trying to do some apparently
somewhat unusual things and running into problems in figuring out how to
do it. In short, I'm trying to develop an application that can show
flight paths on a zoomable world map, eg. New York-London or San
Francisco-Tokyo. Using Layer.PointTrack, I've gotten the basic case of
(x1,y1)-(x2,y2) straight lines working, but...
1) The maps I've tried so far (OpenCarta and OpenStreetMap) don't
"wrap", so if I scroll west of Alaska or east of Japan, I get blank
space instead of the other side of the world. Is there any way to make
this happen?
2) If I want to draw eg. San Fran-Tokyo, the line goes the "long"
(wrong) way across Europe, instead of the correct short way across the
Pacific. It's not too hard to manually split the line in two and render
them separately, but is there a more elegant way of doing this? (Doing
geometrically correct great circle routes would be extra-spiffy.)
3) PointTrack appears to require Geometry.Points, while Markers use
LonLats. Any way to use LonLats for everything? Currently I need to do
this:
var point1 = new OpenLayers.Geometry.Point(-73.778889, 40.639722);
var sourceNode = new OpenLayers.Feature.Vector(point1);
lineLayer.addNodes([sourceNode, targetNode]);
var lonLat = new OpenLayers.LonLat(-73.778889, 40.639722);
var feature = new OpenLayers.Feature(markerLayer, lonLat);
var marker = feature.createMarker();
4) How do I change the style of the lines drawn by PointTrack? Changing
the style of the component Points seems to do nothing:
source/targetNode.style = {strokeColor: '#ff0000', strokeWidth: 10}
still renders in the default style.
5) Can I render arbitrary text instead of icons as Markers? I'd like to
label airports with codes (JFK, LHR, NRT, ...), but there are 17,576 of
them.
I'm getting the feeling that PointTracks may be the wrong approach, and
I should perhaps be using MultiPoints or Curves or LineStrings directly,
but documentation on them seems to be near-absent. Any pointers about
any of this would be much appreciated.
Cheers,
-jani
More information about the Users
mailing list