I am trying to add a map Service layer on Esri basemap and no success. I am wondering if it is possible to do so?
Richard,
I am trying to add a map Service layer on Esri basemap and no success
What have you tried? Is the layer you are adding to the map in WKID 102100 (Web Mercator) as esri basemaps are? Are you adding an ArcGISDynamicMapServiceLayer or an ArcGISTiledMapServiceLayer? You need to provide more detail when you post and code snippets if possible.
Robert
You can try something like the following example.If the dynamic service has different projection than web mercator, it will be reprojected on the fly.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Create Map and add a dynamic layer</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.10/js/esri/css/esri.css"/>
<style>
html, body, #mapDiv{
padding: 0;
margin: 0;
height: 100%;
}
</style>
<script src="http://js.arcgis.com/3.10/"></script>
<script>
var map;
require([
"esri/map",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/ImageParameters"
], function (
Map, ArcGISDynamicMapServiceLayer, ImageParameters) {
map = new Map("mapDiv", {
basemap: "streets",
center: [-83.244, 42.581],
zoom: 15
});
var imageParameters = new ImageParameters();
imageParameters.format = "jpeg"; //set the image type to PNG24, note default is PNG8.
//Takes a URL to a non cached map service.
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapSer...", {
"opacity" : 0.5,
"imageParameters" : imageParameters
});
map.addLayer(dynamicMapServiceLayer);
});
</script>
</head>
<body>
<div id="mapDiv"></div>
</body>
</html>
I will add that I have had an issue with this. I took the example from ESRI and changed the URL to my server and nothing. If I make it a L.esri.FeatureLayer and add the /0 - or whichever feature - to the end of the URL, it displays fine. I just figured our services were published differently.