There are many ways to fix the projection issue, this is one (probably not
the best)
On your view code:
sites_list=sites_list.transform(900913)
Best,
Ariel.
On Tue, Oct 21, 2008 at 1:57 PM, Alfonso <[EMAIL PROTECTED]> wrote:
>
> Hey,
>
> Having great trouble getting geodjango/openlayers to display vector
> markers propery - everything I try positions the sample point off the
> coast of Africa (no matter if I change the vector position in
> geoadmin). Here's what I'm working with - any help appreciated!:
>
> var lon = -2.900;
> var lat = 54.160;
> var zoom = 6;
> var map, baselayer;
> var wkt_f = new OpenLayers.Format.WKT();
> var v_markers = [{% for site in sites_list
> %}wkt_f.read('{{ site.point.wkt }}'){% if not forloop.last %},{% endif
> %}{% endfor %}];
> var marker_style = {'strokeColor' : 'green', 'fillColor' : 'green',
> 'fillOpacity' : 0.9, 'pointRadius' : 6}
> for (var i = 0; i < campsite_markers.length; i++){v_markers[i].style =
> marker_style;}
>
> function init(){
> var options = {
> 'projection' : new OpenLayers.Projection("EPSG:900913"),
> 'units': "m",
> 'maxResolution': 156543.0339,
> 'maxExtent': new
> OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
> 'controls':[new OpenLayers.Control.Navigation(), new
> OpenLayers.Control.ZoomPanel()],
> 'numZoomLevels' : 20,
> };
> // base map
> map = new OpenLayers.Map('map', options);
>
> // - MS Virtual Earth Layer
> baselayer = new OpenLayers.Layer.VirtualEarth("Virtual Earth",
> { 'type': VEMapStyle.Street, "sphericalMercator": true});
> map.addLayer(baselayer);
>
> // Controls for the map
> map.addControl(new OpenLayers.Control.LayerSwitcher());
> map.addControl(new OpenLayers.Control.MousePosition());
>
> var layermarkers = new OpenLayers.Layer.Vector("markers");
> layermarkers.addFeatures(v_markers);
>
> // Vector Layers for the sites
> var LonLat = new OpenLayers.LonLat(lon, lat).transform(new
> OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());
>
> map.addLayer(layermarkers);
> map.setCenter(LonLat, zoom);
>
> }
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---