question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

proj4 is not defined in TiledMapLayer

See original GitHub issue
  • Browser and version: Any browser you like
  • Version of Leaflet (L.version): 1.2.0
  • Version of esri Leaflet (L.esri.VERSION): 2.1.1
  • Steps to reproduce the error:
  1. Use Leaflet and esri-leaflet together with proj4leaflet
  2. proj4leaflet has a dependency of proj4
  3. Import proj4leaflet AMD style without importing proj4 manually anywhere else since proj4leaflet will pick it up from dependencies and will work fine

What happens is that when doing this I will get an error on this line https://github.com/Esri/esri-leaflet/blob/master/src/Layers/TiledMapLayer.js#L141 saying Uncaught ReferenceError: proj4 is not defined.

I was expecting for this to work fine, since only the proj4leaflet library is dependant on proj4 and esri-leaflet is not.

It is quite hard to replicate this problem using jsbin, since I use npm and package.json and webpack.

  • Optional: I’m not using the CDN, I’m loading/bundling the library using: Webpack

Adding this as a workaround helps to get it work and no errors are shown, but I think that should not be required for esri-leaflet to work without issues.

import * as proj4 from 'proj4';
window['proj4'] = proj4;

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jgravoiscommented, Oct 26, 2017

thanks for the report. i’ll have to think about how we might make this check more friendly for bundlers.

luckily the issue is pretty benign (ie: we’re just logging an irrelevant error in the console in some situations where proj4 is available).

1reaction
advanceditscommented, Feb 8, 2018

Yeap, you are right, we did use dynamicMapLayer and had issues…not sure if it was performance I have notified the data provider, thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Proj4js in Openlayers - Proj4js is not defined
I get a javascript error: ReferenceError: Proj4js is not defined . When I look at the source specified at /cdnjs.cloudflare.com/ajax/libs/ ...
Read more >
Solved: esri leaflet map services
I've set-up my map how I want it, added a few feature layers and ... tiledMapLayer({ url: 'https://services.geodataonline.no/arcgis/rest/ ...
Read more >
Project and display a feature layer | Esri Leaflet
Project and display a feature layer. You can project a feature layer using non-Mercator tiles using L.esri.TiledMapLayer and the Proj4Leaflet plugin.
Read more >
babeljs - Openlayers proj not defined issue - Stack Overflow
Openlayers (5.1.3) app bundled with browserify and babel: import {Map, View} from 'ol'; import TileLayer from 'ol/layer/Tile'; import OSM from ' ...
Read more >
TiledMapLayer - FDOT GIS Framework
new TiledMapLayer(options: TiledMapLayerOptions): TiledMapLayer. Overrides TileLayer.constructor. Defined in src/typings/leaflet/esrileaflet.d.ts:129 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found