<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Adding Map Services with Custom Tiling Schemes to Leaflet in Open Source Mapping Libraries Ques.</title>
    <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-map-services-with-custom-tiling-schemes-to/m-p/799656#M332</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;very cool patrick!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Oct 2016 18:16:08 GMT</pubDate>
    <dc:creator>JohnGravois</dc:creator>
    <dc:date>2016-10-21T18:16:08Z</dc:date>
    <item>
      <title>Adding Map Services with Custom Tiling Schemes to Leaflet</title>
      <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-map-services-with-custom-tiling-schemes-to/m-p/799655#M331</link>
      <description>&lt;P&gt;I have been developing data visualization web mapping applications for various Cumberland County departments using the &lt;A href="http://leafletjs.com/" target="_blank" rel="nofollow noopener noreferrer"&gt;Leaflet&lt;/A&gt; JavaScript library. &amp;nbsp;All of these apps have used the standard WGS84 Web Mercator Auxiliary Sphere projection/tiling scheme. &amp;nbsp;This is used in Google Maps, ArcGIS Online, and the other major web map players.&lt;/P&gt;
&lt;P&gt;And while this works just fine, I wondered if there was a way to build web maps using the custom projection and tiling scheme we use for our tiled map services. &amp;nbsp;It turns out there is - but it requires a few plugins.&lt;/P&gt;
&lt;P&gt;The first is &lt;A href="http://proj4js.org/" target="_blank" rel="nofollow noopener noreferrer"&gt;Proj4js&lt;/A&gt;, which “ transform&lt;S&gt; point coordinates from one coordinate system to another, including datum transformations.” &amp;nbsp;&lt;/S&gt;&lt;/P&gt;
&lt;P&gt;The second is &lt;A href="http://kartena.github.io/Proj4Leaflet/" target="_blank" rel="nofollow noopener noreferrer"&gt;Proj4Leaflet&lt;/A&gt;, which “makes it possible to use projections and CRS not built into Leaflet.” &amp;nbsp;CRS stands for Coordinate Reference System.&lt;/P&gt;
&lt;P&gt;I thought I would share the process for using Esri REST services with custom projections/tiling schemes in a Leaflet web map. &amp;nbsp;You can find the example on &lt;A href="http://codepen.io/pmckinney/pen/ambpgj" target="_blank" rel="nofollow noopener noreferrer"&gt;CodePen&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;When I was learning how to do this, I referenced the &lt;A href="http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html" target="_blank" rel="nofollow noopener noreferrer"&gt;example&lt;/A&gt; from the Esri Leaflet documentation site. &amp;nbsp;We’ll use Cumberland County’s 2015 Existing Land Use service for this demo.&lt;/P&gt;
&lt;P&gt;The service uses the Pennsylvania State Plane South (ft) projection, or EPSG 2272 as it is also known. &amp;nbsp;The spatial reference for your Esri REST service can be found at the service’s endpoint URL.&lt;/P&gt;
&lt;P&gt;You can get the information for your specific projection from the &lt;A href="http://spatialreference.org/" target="_blank" rel="nofollow noopener noreferrer"&gt;Spatial Reference&lt;/A&gt;&amp;nbsp;website. &amp;nbsp;Here is sample of what you’ll get from this website to construct the custom CRS for your service:&lt;/P&gt;
&lt;BLOCKQUOTE class="jive-quote"&gt;+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs&lt;/BLOCKQUOTE&gt;
&lt;P&gt;We also need some information about the service itself. &amp;nbsp;This includes the origin, and resolution for each zoom level. &amp;nbsp;These can also be found at the service’s endpoint URL. &amp;nbsp;Below is an image showing where this information is located:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/249311_esri-rest-service-tile-info-capture.PNG" border="0" alt="snippet of Esri REST service endpoint website" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code snippet for creating the custom CRS for the Existing Land Use service:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-none" tabindex="0"&gt;&lt;CODE&gt;var spcPACrs = new L.Proj.CRS(
 'EPSG:2272', 
 '+proj=lcc +lat_1=40.96666666666667 +lat_2=39.93333333333333 +lat_0=39.33333333333334 +lon_0=-77.75 +x_0=600000 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_defs', {
origin: [-1.192142E8, 1.461669E8],
resolutions: [
260.41666666666663,
86.80555555555556,
43.40277777777778,
20.833333333333332,
10.416666666666666,
6.944444444444444,
4.166666666666666,
2.083333333333333,
1.0416666666666665,
0.5208333333333333
]
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now that we have created our custom CRS, we can construct the service. &amp;nbsp;We will be using the &lt;/SPAN&gt;&lt;A href="http://esri.github.io/esri-leaflet/api-reference/layers/tiled-map-layer.html" target="_blank" rel="nofollow noopener noreferrer"&gt;tiledMapLayer class&lt;/A&gt;&lt;SPAN&gt; from the Esri Leaflet library. &amp;nbsp;It should be noted that by default, you can only use this class for tiled map services that use the WGS84 Web Mercator Auxiliary Sphere projection. &amp;nbsp;You need the above referenced plugins to use other projections/tiling schemes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-none" tabindex="0"&gt;&lt;CODE&gt;var ccpaELU = L.esri.tiledMapLayer({
url: '//gis.ccpa.net/arcgiswebadaptor/rest/services/ELU/MapServer',
maxZoom: 8,
minZoom: 0,
continuousWorld: true,
attribution: 'Cumberland County',
errorTileUrl: '//downloads2.esri.com/support/TechArticles/blank256.png'
}).addTo(map);‍‍‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some of the options you can set are the minimum and maximum zoom levels for the service. &amp;nbsp;The numbers should match the Level ID numbers found at the service’s endpoint URL. &amp;nbsp;&amp;nbsp;You also have options to set an image for any places where the tiles fail to load. &amp;nbsp;As the &lt;STRONG&gt;tiledMapLayer &lt;/STRONG&gt;inherits from Leaflet’s &lt;STRONG&gt;tileLayer &lt;/STRONG&gt;class, all of it’s &lt;A href="http://leafletjs.com/reference.html#tilelayer" target="_blank" rel="nofollow noopener noreferrer"&gt;options &lt;/A&gt;can be used with the tiledMapLayer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully you have found this article helpful. &amp;nbsp;To see this example in action, please visit the &lt;A href="http://codepen.io/pmckinney/pen/ambpgj" target="_blank" rel="nofollow noopener noreferrer"&gt;CodePen&lt;/A&gt; site. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 13:26:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-map-services-with-custom-tiling-schemes-to/m-p/799655#M331</guid>
      <dc:creator>PatrickMcKinney1</dc:creator>
      <dc:date>2023-08-28T13:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding Map Services with Custom Tiling Schemes to Leaflet</title>
      <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-map-services-with-custom-tiling-schemes-to/m-p/799656#M332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;very cool patrick!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2016 18:16:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-map-services-with-custom-tiling-schemes-to/m-p/799656#M332</guid>
      <dc:creator>JohnGravois</dc:creator>
      <dc:date>2016-10-21T18:16:08Z</dc:date>
    </item>
  </channel>
</rss>

