[OpenLayers-Users] Basic marker questions

Mike Purvis mike at uwmike.com
Wed May 5 07:37:58 EDT 2010


Hi Marjie,

This is what I have so far: http://sandbox.mikepurvis.com/maps/clearpath/

(doubleclick to create more waypoints)

Like I say, it's a real hack, especially this kind of stuff:

        var lonlatProjected = map.getLonLatFromViewPortPx(e.xy);

        /*alert("You clicked near " + lonlatProjected.lat + " N, " +
> lonlatProjected.lon + " E");*/



        var point = new OpenLayers.Geometry.Point(lonlatProjected.lon,
> lonlatProjected.lat);

        var pointFeature = new OpenLayers.Feature.Vector(point, null,
> style_waypoint);

        vectorLayer.addFeatures([pointFeature]);


If you re-enable the alert, you see that it's very clearly _not_ a true
latitude and longitude coming out of the getLonLatFromViewPortPx—it's a
coordinate pair in some other scheme that's been packaged into a LonLat.

Perhaps one of the gurus could help break this down a bit for me. Is this an
expected behaviour, or did I do something wrong in the setup phase? My
understanding so far is that Pixel is for x/y pairs representing screen
coordinates, LonLat is for x/y pairs representing global coordinates, and
Point is for unitless x/y pairs representing anything that needs to be
transformed or otherwise manipulated. Is that reasonable, or am I still out
to lunch on it?

Thanks,

Mike


On Wed, May 5, 2010 at 12:19 AM, Marjie Anderson <marjiea1 at gmail.com> wrote:

>  I would love to see an example of how you got this working in code.
>
>
>
> I  am having problems with hand parsing a kml file to pull out the zoom box
> points and use them for bounds, pull out the marker point and use that for
> the lonlat, and then letting the automatic kml loader load the linestrings
> in the kml file that show all the points hooked together of where my vehicle
> has been.  I can get it working without the spherical mercator (and the
> markers not in the right place on the commercial layers), but once I follow
> the directions for mercator using the forwardMercator calls:
>
>
>
> marker = new
> OpenLayers.Marker(OpenLayers.Layer.SphericalMercator.forwardMercator(lon,
> lat));
>
>
>
> I get neither markers nor linestrings.
>
>
>
> I am unable to request help here for this issue as I cannot get the
> non-mercator version to run on my current server space, only on my
> development laptop.
>
>
>
> Marjie
>
>
>
> * *
>
> * *
>
> *“*Okay, yes, I have now got this working, but it's been extremely
> painful. I can share my code for others if it would be helpful to do so, but
> I feel certain that there must be a better way. It feels extremely hacky to
> be constantly loading lat/lon pairs into Point objects, just to "transform"
> them to the map coordinates. (Which, of course, the map methods still refer
> to and interact with as LonLat objects, even the contents are clearly not
> latitudes and longitudes, but another coordinate system altogether.)
>
>
>
> Seems like if I pass it LonLat objects, it just know to do the right thing,
> as Google does.”
>



-- 
http://uwmike.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100505/d6f5e91c/attachment.html


More information about the Users mailing list