皆さん、こんにちは、
meteorでleafletマップを表示するシンプルなアプリを作っていて、npmパッケージ"esri-leaflet"を使っています。しかし動作しません。これが私のコードです:
Html:
<div id="viewDiv"> Explore D3 </div> </template> javascript:<\/CODE><\/PRE> <PRE class="lia-code-sample line-numbers language-none" tabindex="0"><CODE>onRendered(){ L = require('esri-leaflet') var map = L.map('viewDiv').setView([45.528, -122.680], 13); L.esri.basemapLayer("Gray").addTo(map); var parks = L.esri.featureLayer({ url: "http:\/\/gis.d3smartcity.ae\/arcgis\/rest\/services\/Operation_layers\/d3_Masterplan\/MapServer", style: function () { return { color: "#70ca49", weight: 2 }; } }).addTo(map); var popupTemplate = "<h3>{NAME}</h3>{ACRES} Acres<br><small>Property ID: {PROPERTYID}<small>"; parks.bindPopup(function (e) { return L.Util.template(popupTemplate, e.feature.properties) }); } しかし、いつも同じ問題が発生します: どんな助けでも感謝します!
Dadi,
I don't work with Meteor so I can't speak to using that framework but I noticed that you're not passing a feature layer URL in your featureLayer constructor. You'll need to point to a specific layer number.
L.map is not a function is what the error screams. I'm not a Meteor user but you usually see this when the app doesn't see the library.
In the Esri example they also call the Leaflet Library, your example just refers to the Esri lib not the Leaflet Lib. I believe you need both. Once your app can see the Library it show draw the map.
<SPAN class=""><!-- Load Leaflet from CDN--></SPAN> <SPAN class=""><SPAN><link rel="stylesheet" href="</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Funpkg.com%2Fleaflet%401.0.0%2Fdist%2Fleaflet.css" target="_blank">https://unpkg.com/leaflet@1.0.0/dist/leaflet.css</A><SPAN>" /></SPAN></SPAN> <SPAN class=""><SPAN><script src="</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Funpkg.com%2Fleaflet%401.0.0%2Fdist%2Fleaflet-src.js" target="_blank">https://unpkg.com/leaflet@1.0.0/dist/leaflet-src.js</A><SPAN>"></SPAN></SPAN><SPAN class=""></SPAN><SPAN class=""></script></SPAN> <SPAN class=""><!-- Load Esri Leaflet from CDN --></SPAN> <SPAN class=""><SPAN><script src="</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Funpkg.com%2Fesri-leaflet%402.0.4" target="_blank">https://unpkg.com/esri-leaflet@2.0.4</A><SPAN>"></SPAN></SPAN><SPAN class=""></SPAN><SPAN class=""></script></SPAN>
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.