marcobarons

Some problems to link a layer from Arcgis online on openlayers. Help me please  ;-)

Discussion created by marcobarons on Jan 15, 2014
Latest reply on Jan 15, 2014 by JUihlein-esristaff
Hello everyone, I have some problems to link layers Arcgis online on openlayers. Can you help me ? Please. Here is the code:

[HTML]<html>
<head>
<title>Carte</title>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
 
  // Constructor of the map
 
  var map = new OpenLayers.Map('map');
 
 
  // Put coordonate
 
     map.addControl(
                new OpenLayers.Control.MousePosition({
                    prefix: '<a target="_blank" ' +
                        'href="http://spatialreference.org/ref/epsg/4326/">' +
                        'EPSG:4326</a> coordinates: ',
                    separator: ' | ',
                    numDigits: 2,
                    emptyString: 'Mouse is not over map.'
                })
            );

  // Put basemap and layers.
 
   var layer = new OpenLayers.Layer.OSM( "Simple OSM Map");
  
   var ol = new OpenLayers.Layer.OSM("Simple carte");
  
   arcgislayer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                                            "http://services2.arcgis.com/D0xrg9UqZz6klOA4/arcgis/rest/services/TEST_EHANIA/FeatureServer/0",
                                            {'layers': 'basic'},
                                            {'maxExtent': new OpenLayers.Bounds(-180,-90,180,90),
                                             'maxResolution': "auto"});
  
  
  
   map.addLayer(layer);
       
  
   map.zoomToMaxExtent();
  
  
  
  
  
 
 
 
  // Put Marker.
 
     var markers = new OpenLayers.Layer.Markers( "Markers" );
  map.addLayer(markers);

    var size = new OpenLayers.Size(45,50);
    var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
    var icon = new OpenLayers.Icon('http://fc07.deviantart.net/fs71/f/2013/201/6/9/super_mario_png_by_brokenheartdesignz-d6ebndw.png', size, offset);
    markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(4.18,50.28),icon));
    markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(4.18,50.28),icon.clone()));

    //Vector.
  
   var start_point = new OpenLayers.Geometry.Point(0,10);
var end_point = new OpenLayers.Geometry.Point(30,0);
var point_test = new OpenLayers.Geometry.Point(10,15);


var vector = new OpenLayers.Layer.Vector("Vecteurs");
vector.addFeatures([new OpenLayers.Feature.Vector(new OpenLayers.Geometry.LineString([start_point, end_point,point_test]).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")))]);
map.addLayers([ol,vector]);
map.setCenter(new OpenLayers.LonLat(0, 5), 3);
   
   
    // switcheur.
   
    map.addControl(new OpenLayers.Control.LayerSwitcher());
   
   
  
   
   
 
 

</script>
</body>
</html>[/HTML]

The Url service is " "http://services2.arcgis.com/D0xrg9UqZz6klOA4/arcgis/rest/services/TEST_EHANIA/FeatureServer/0 "

Your help is precious.  Thank you.

Outcomes