[OpenLayers-Users] marker help with tilecache

Eric Lemoine eric.c2c at gmail.com
Wed Mar 5 11:27:04 EST 2008


Hello, you're mixing projections, which looks suspicious to me.

2008/3/5, Aco <acopetko at gmail.com>:
>
> I am still trying to figure out this problem, please any help would be
> appreciated.
> I really cannot find a solution anywhere else and my biggest hope is this
> forum.
> Any thoughts ?
>
> Thanks Again,
>
> Aleks
>
>
>
> Aco wrote:
> >
> > Hi and thanks to all the replies in advance,
> >
> > I am relatively new to tilecache. I have installed it on windows and it
> > works fine, but the problem is that is when i want to add an openlayers
> > marker, well it just doesn't display it. It displays it when I am not
> > using
> > tilecache to cache the image tiles.
> >
> > Here is my html.
> >
> > <html xmlns="http://www.w3.org/1999/xhtml">
> >   <head>
> >     <style type="text/css">
> >         #map {
> >             width: 100%;
> >             height: 99%;
> >             border: 1px solid black;
> >         }
> >     body {
> >       padding:0px;
> >       margin:2px
> >     }
> >     #labs {
> >      position:absolute;
> >      bottom:15px;
> >      left:7px;
> >      font-size:smaller;
> >      z-index: 5000;
> >         }
> >     </style>
> >     <script src="http://openlayers.org/api/OpenLayers.js"></script>
> >     <!--<script type="text/javascript" src="C:/Tomcat6/webapps
> > /examples/Whitesnow/js/main_actions_1.0.js"></script>-->
> >     <script type="text/javascript">
> >         <!--
> >         var lon = 5;
> >         var lat = 40;
> >         var zoom = 5;
> >         var points = [];
> >         var map, layer, polygonLayer, markers, points_ring,
> > area_of_interest_polygon, area_of_interest_feature, ol_wms, mouse;
> >         var icon_size = new OpenLayers.Size(1700,1700);
> >
> >         var coords_lat = new Array();
> >         var coords_lon = new Array();
> >
> >         var vector_style = OpenLayers.Util.extend({},
> > OpenLayers.Feature.Vector.style['default']);
> >             vector_style.strokeColor = "#7F0000";
> >             vector_style.fillColor = "red";
> >
> >         function init(){
> >             var options = {
> >                 units: "m",
> >             projection: 'epsg:32661',
> >             resolutions: [5500000.0,2750000.0,1375000.0,687500.0,343750.0,
> > 171875.0,85937.5, 42968.75,21484.375,10742.1875,5371.09375,2685.546875,
> > 1342.7734375,671.38671875,335.693359375,167.8466796875,83.92333984375,
> > 41.961669921875,20.9808349609375,10.49041748046875],
> >                 maxExtent: new OpenLayers.Bounds
> > (-2200000,-712631,3072800,3840000)
> >                 };
> >            var options2 = {
> >                 units: "m",
> >                 maxResolution: "auto",
> >             projection: "EPSG:3573",
> >                 resolutions: [5500000.0, 2750000.0, 1375000.0, 687500.0,
> > 343750.0, 171875.0, 85937.5, 42968.75, 21484.375, 10742.1875, 5371.09375,
> > 2685.546875, 1342.7734375, 671.38671875, 335.693359375, 167.8466796875,
> > 83.92333984375, 41.961669921875, 20.9808349609375, 10.49041748046875],
> >             maxExtent: new OpenLayers.Bounds
> > (-4000000,-4200000,3000000,3500000)
> >                 };
> >             map = new OpenLayers.Map( 'map');
> >
> >             ol_wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
> >                           "http://labs.metacarta.com/wms/vmap0?", {layers:
> > 'basic', srs: 'epsg:42304'});
> >
> >              polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer");
> >              markers = new OpenLayers.Layer.Markers( "Markers" );
> >
> >
> >
> >             layer = new OpenLayers.Layer.WMS( "Openlayers WMS",
> >                    "
> > http://lakeice.uwaterloo.ca/TileCache-2.01/tilecache.cgi?", {layers:
> > 'nsidc_polar', format: 'image/png' },options2 );
> >
> >             map.addLayer(ol_wms);
> >
> >           //  map.addControl(new OpenLayers.Control.Permalink());
> >             if (!map.getCenter()) map.zoomToMaxExtent();
> >
> >
> >
> >             mouse = new OpenLayers.Control.MousePosition();
> >             map.addControl(mouse);
> >
> >             // markers.clearMarkers();
> >              //var marker = new OpenLayers.Marker(new OpenLayers.LonLat(0,
> > 0), new OpenLayers.Icon("
> > http://lakeice.uwaterloo.ca/TileCache-2.01/target2.png", icon_size));
> >              //markers.addMarker(new OpenLayers.Marker(new
> > OpenLayers.LonLat(0,
> > 0), new OpenLayers.Icon("
> > http://lakeice.uwaterloo.ca/TileCache-2.01/target2.png", icon_size)));
> >             // markers.addMarker(new OpenLayers.Marker(new
> > OpenLayers.LonLat
> > (-5859.37500, -27734.37500), new OpenLayers.Icon("
> > http://lakeice.uwaterloo.ca/TileCache-2.01/target2.png", icon_size)));
> >
> >             map.events.register("click", map, function(e) {
> >          if (coords_lon.length < 4) {
> >        // alert("no");
> >             var lonlat = map.getLonLatFromViewPortPx(e.xy);
> >             coords_lon.push(lonlat.lon);
> >             coords_lat.push(lonlat.lat);
> >           // setOutputPoints();
> >             drawUniversalSelection();
> >          }
> >       });
> >
> >
> >             }
> >
> >       function drawUniversalSelection() {
> >
> >          points.length = 0;
> >          markers.clearMarkers();
> >          for (var x = 0; x < coords_lon.length; x++) {
> >             var marker = new OpenLayers.Marker(new
> > OpenLayers.LonLat(coords_lon[x],
> > coords_lat[x]), new OpenLayers.Icon("target2.png", icon_size));
> >             points[x] = new OpenLayers.Geometry.Point(coords_lon[x],
> > coords_lat[x]);
> >             markers.addMarker(marker);
> >              map.addLayer(markers);
> >         //alert("yep");
> >
> >          }
> >
> >          if (coords_lon.length > 1) {
> >             points.push(points[0]);
> >            //   alert("yep");
> >          }
> >          points_ring = new OpenLayers.Geometry.LinearRing(points);
> >          area_of_interest_polygon = new OpenLayers.Geometry.Polygon
> > (points_ring);
> >          area_of_interest_feature = new OpenLayers.Feature.Vector
> > (area_of_interest_polygon,null,vector_style);
> >          polygonLayer.destroyFeatures();
> >          polygonLayer.addFeatures([area_of_interest_feature]);
> >           map.addLayer(polygonLayer);
> >
> >       }
> >         // -->
> >     </script>
> >   </head>
> >   <body onload="init()">
> >     <div id="map">
> >     <div id="labs">From  http://labs.metacarta.com/ MetaCarta
> > Labs .</div>
> >     </div>
> >   </body>
> > </html>
> >
> >
> > Thanks in advance,
> >
> >
> > Aleks
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/marker-help-with-tilecache-tp15834699p15854144.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list