Awesome. I should be able to run with this. Thanks, -m.
On Tue, Apr 24, 2012 at 12:42 PM, Greg Allensworth <[email protected]> wrote: >> I'm using PHP to create the image. So, I'm guessing I'll be using the >> GD Library in order to draw on the image. > > > Oh, that's good. As you point out, if you can convert from map coords to > pixels you may have what you need. > > > >> Then the trick will be to translate from the coordinate system from >> the map to the image. Is this a matter of using the lat/lon info of >> the Vector features compared to a lat/lon from the map that represents >> the origin? Or does OpenLayers provide coordinate properties for the >> features that can be used for this purpose? > > > Not directly, but it's easy to derive: Vector features have a Geometry, and > Geometry objects have getVertices(), and Map has getPixelFromLonLat() > > The "location" of getVertices() varies depending on whether you're doing > lines or polygons or multipolygons, and is irrelevant if you're doing Point > geometries, so you may need a switch around the geometry type. > > But, here's some pseudocode outlining the basic idea: > > for (var f=layer.features) { > geom = feature[f].geometry; > > switch (geom.CLASS_NAME) { > > case OpenLayers.Geometry.Point > p = map.getPixelFromLonLat(v.x,v.y); > > case OpenLayers.Geometry.LineString > for (var v=geom.getVertices() ) { > p = map.getPixelFromLonLat(v.x,v.y); > } > > case OpenLayers.Geometry.Polygon > for (var ring = geom.components) { > for (var v=ring.getVertices() ) { > p = map.getPixelFromLonLat(v.x,v.y); > } > } > > > } // end of geom type switch > } // end of feature loop > > > -- > Greg Allensworth, Web GIS Developer > BS A+ Network+ Security+ Linux+ Server+ > GreenInfo Network - Information and Mapping in the Public Interest > 564 Market Street, Suite 510 San Francisco CA 94104 > PH: 415-979-0343 x302 FX: 415-979-0371 email: [email protected] > Web: www.GreenInfo.org www.MapsPortal.org > > Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
