Pomáhám kolegovi s malou aplikací leaflet. Narazili jsme na problém při pokusu přidat naši vlastní službu podkladové mapy pomocí metody 'L.tiledMapLayer'. Předpokládám, že problém je v naší mapové službě, ale tuto službu úspěšně používáme v několika vlastních javascriptových aplikacích, stejně jako v dalších aplikacích ESRI a GeoCortex. <\/P>
Při použití URL podkladové mapy ESRI to zdá se fungovat dobře:<\/P>
<\/P>
L.esri.tiledMapLayer({ url: "<\/SPAN>http:\/\/services.arcgisonline.com\/arcgis\/rest\/services\/World_Topo_Map\/MapServer<\/A>"<\/SPAN>}).addTo(map);<\/P> <\/P>Nicméně při výměně URL ESRI za naši vlastní (nezabezpečenou a veřejně přístupnou) dlaždicovou službu se podkladová mapa nezobrazí a nástroje pro vývojáře ukazují spoustu chyb 404 Not found pro dlaždice.<\/P> <\/P>L.esri.tiledMapLayer({ url: "<\/SPAN>https:\/\/maps2.tucsonaz.gov\/arcgis\/rest\/services\/BaseMaps\/gisBaseMap_Topo\/MapServer<\/A>"<\/SPAN>}).addTo(map);<\/P> <\/P>Zajímalo by mě, jestli je to nastavení v naší službě, takže jak je aktuálně nakonfigurováno, nebude fungovat s Leaflet?<\/P> <\/P>Díky - <\/P>Allen<\/P>
there were a few different things going on causing problems.
1. your own service doesn't support making CORS requests. thats okay, but its necessary for you to pass through `useCors: false` in your own constructor
2. even though your service advertises itself as wkid: 3857, its actually using a custom XY for its origin, which is problematic when the internal API attempts to translate the global LODs the service is missing.
3. there was a bug in esri-leaflet that led to us attempting to override custom LODs provided in code when we recognized the coordinate system as web mercator. (i fixed that here and published v2.1.2).
all that said, in our latest release, we display the service correctly, but its still up to you to describe the custom projection in your own code.
<SPAN class="keyword token">var</SPAN> crs <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">L<SPAN class="punctuation token">.</SPAN>Proj<SPAN class="punctuation token">.</SPAN>CRS</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"EPSG:3857"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> origin<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="operator token">-</SPAN><SPAN class="number token">20037700</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">30241100</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="comment token">// your origin is custom</SPAN> resolutions<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">[</SPAN> <SPAN class="number token">611.4962262813797</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="comment token">// you are missing some smaller scale LODS as well</SPAN> <SPAN class="number token">305.74811314055756</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">152.87405657041106</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="comment token">// ...</SPAN> <SPAN class="punctuation token">]</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> map <SPAN class="operator token">=</SPAN> L<SPAN class="punctuation token">.</SPAN><SPAN class="token function">map</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'map'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> crs<SPAN class="punctuation token">:</SPAN> crs <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">setView</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">32.2217</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="operator token">-</SPAN><SPAN class="number token">110.926</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> L<SPAN class="punctuation token">.</SPAN>esri<SPAN class="punctuation token">.</SPAN><SPAN class="token function">tiledMapLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>'</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fmaps2.tucsonaz.gov%2Farcgis%2Frest%2Fservices%2FBaseMaps%2FgisBaseMap_Topo%2FMapServer" target="_blank">https://maps2.tucsonaz.gov/arcgis/rest/services/BaseMaps/gisBaseMap_Topo/MapServer</A><SPAN>'</SPAN></SPAN><SPAN class="punctuation token">,</SPAN> useCors<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">false</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">addTo</SPAN><SPAN class="punctuation token">(</SPAN>map<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
live sample: http://jsbin.com/yovezox/edit?html,output
(based on the sample in our documentation here)
my pleasure. to answer your follow up question, no. i'd expect the workflow you describe above to result in a published service CRS that is identical to Google/Bing/ArcGIS Online.
https://services.arcgisonline.com/arcgis/rest/services/World_Topo_Map/MapServer
John - Many thanks for looking in to this and the detailed response. This works well, and has helped us understand some implications of our basemap-building decisions.
So just to clarify - the source data used to build our basemap is in our local State Plane system but we make the data frame Web Mercator (without re-projecting the individual feature classes) in order to make it more friendly in web applications. This is what creates the need for the extra coding within leaflet, correct?
Allen
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.