Select to view content in your preferred language

how to use arcgis-leaflet with meteor js?

1731
2
10-24-2016 09:32 AM
meriammme
Deactivated User

Hi everyone,

I'm making a simple app to show leaflet map with meteor and I'm using the package npm "esri-leaflet".But it doesn't work.This is my code :

Html:

<div id="viewDiv">    Explore D3 </div> </template>
javascript&colon;
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)     }); }

But I have always the same problem : 
I'll be thankful for any help!
0 Kudos
2 Replies
SethLewis1
Frequent Contributor

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.

0 Kudos
BillChappell
Frequent Contributor

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.

  <!-- Load Leaflet from CDN-->  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.0/dist/leaflet.css" />  <script src="https://unpkg.com/leaflet@1.0.0/dist/leaflet-src.js"></script>   <!-- Load Esri Leaflet from CDN -->  <script src="https://unpkg.com/esri-leaflet@2.0.4"></script>
0 Kudos