Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error 404 loading - cannot import L.Control.Locate.min #2

Open
fpcorcoran opened this issue Apr 3, 2019 · 5 comments
Open

Error 404 loading - cannot import L.Control.Locate.min #2

fpcorcoran opened this issue Apr 3, 2019 · 5 comments

Comments

@fpcorcoran
Copy link

I'm trying to get the .js and .css for the L.Control.Locate function, but the server is not responding. What do I need to do to get these in? Code and error are below:

Code:
`

<!-- Javascript Imports -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.4.0/leaflet.js" integrity="sha256-6BZRSENq3kxI4YYBDqJ23xg0r1GwTHEpvp3okdaIqBw=" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore.js" integrity="sha256-O4179En8zabOlPYBNvGp8cF0uh0vnSZpW4Q6Ul1h+8c=" crossorigin="anonymous"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>

<!-- add leaflet plugin here -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet.locatecontrol@[VERSION]/dist/L.Control.Locate.min.css" />

<script src="https://cdn.jsdelivr.net/npm/leaflet.locatecontrol@[VERSION]/dist/L.Control.Locate.min.js" charset="utf-8"></script>

<!-- import main.js -->
<script src="js/main.js"></script>`

Console Error:

[Error] Failed to load resource: the server responded with a status of 404 () (L.Control.Locate.min.js, line 0)

[Error] Failed to load resource: the server responded with a status of 404 () (L.Control.Locate.min.css, line 0)

[Error] Refused to execute https://cdn.jsdelivr.net/npm/leaflet.locatecontrol@[VERSION]/dist/L.Control.Locate.min.js as script because "X-Content-Type: nosniff" was given and its Content-Type is not a script MIME type.

[Error] TypeError: L.control.locate is not a function. (In 'L.control.locate({
postition: 'top right'
})', 'L.control.locate' is undefined)
Global Code (main.js:27)

@rossbernet
Copy link
Member

rossbernet commented Apr 3, 2019

We did this in class, but you missed it because you weren't there, but:

Take a look here:
https://github.com/domoritz/leaflet-locatecontrol#add-the-javascript-and-css-files

Youll need to delete the @VERSION in the CDN import URL

@fpcorcoran
Copy link
Author

Ahh ok. I’d been looking at that documentation but was under the impression the @Version would just give me the most recent version.

@rossbernet
Copy link
Member

It’s a little confusing for sure. Did that resolve it?

@fpcorcoran
Copy link
Author

Removing the @Version did make the script and css imports work, but I'm still not seeing my location pop up on the map when I open the html. No messages in the console to indicate why that's the case.

@rossbernet
Copy link
Member

There is one more step. Did you add the console?

And then a button should appear on the html you’ll have to click.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants