Comments (6)
Hi @mm-ns!
I forgot to check if FullscreenControl constructor was undefined. I will update a new version fixing this, sorry!
About your other question, you can inject mapboxglMapsData
factory and you can use getMapById
method to get the map instance. Something like:
<div mapbox-gl id="myMap"></div>
app.controller('MyController', ['$scope', 'mapboxglMapsData', function ($scope, mapboxglMapsData) {
$scope.$on('mapboxglMap:load', function () {
var mapInstance = mapboxglMapsData.getMapById('myMap');
// ...
});
}]);
Tell me if it worked!
from angular-mapboxgl-directive.
Hi @mm-ns!
What version of mapboxgl and angular-mapboxgl-directive are you using? Can you provide me an example in codepen or in other platform?
from angular-mapboxgl-directive.
Hi @Naimikan,
I can try to see if I can reproduce that in a plunkr or similar. It looks like some variables, controls, or whatever is left over and not re-initialized. Ill work on making it now...
from angular-mapboxgl-directive.
Hi there. I made a plunkr here: https://plnkr.co/edit/HY2tR5MSliZKU9Q3fLB6?p=preview
However I wasn't able to replicate the issue :( I tried to follow my own structure, I tried to simulate ajax requests with timeouts, etc, but no luck :(
I tried to add a console.log() locally on my machine in the angular-mapboxgl-directive in the "checkObjects" method (around line 1739) to print the "eachObject" object, which is where I get a bunch of issues, and when you land on dashboard page for the first time, this is what you see in console.log():
If i browser anywhere else and come back in there, this is what I now see:
Not sure what to make of this or how to replicate it... The only difference is my script are using "defer". which is why you will see only this as issue in plunkr (which doesnt occur though locally with your library).
Any idea you may have would be greatly appreciate.
from angular-mapboxgl-directive.
Oh I just tried to load <script defer src="https://cdnjs.cloudflare.com/ajax/libs/angular-mapboxgl-directive/0.33.0/angular-mapboxgl-directive.js"></script>
0.33 from cdns instead of my local version and I don't experience that issue any longer!!! only have that "TypeError: Cannot read property 'name' of undefined" on angular-mapboxgl-directive.js:746 which is due to the fact that mapboxgl.FullscreenControl is undefined. As a result, none of the controls will be displayed on the map. I added something I typically do, which is instead of doing:
{ name: 'fullscreen', constructor: mapboxgl.FullscreenControl, pluginName: 'mapboxgl.' + mapboxgl.FullscreenControl.name }
I do
{ name: 'fullscreen', constructor: (mapboxgl.FullscreenControl || {}), pluginName: 'mapboxgl.' + (mapboxgl.FullscreenControl || {}).name }
Of course I wouldn't know that FullscreenControl is undefined, but at least it doesn't break anything..
One thing I have been wondering is how do I get the map object itself via the directive?
I am trying to turn off and off certain layers, and I although I made a service to store the current map so I can retrieve on click on a custom control. Not sure whether that's the best way to do it :D
from angular-mapboxgl-directive.
Hi @Naimikan
No worries! I appreciate your work, it's great.
from angular-mapboxgl-directive.
Related Issues (20)
- Navigation control does not work HOT 4
- Invalid source ID HOT 1
- Markers lose its position during scroll HOT 6
- How can I use an image as an icon-image for the 'unclustered-point' layer? HOT 1
- Map doesn't handle data changes after any events HOT 2
- Save and load polygon drawn with mapbox draw tool
- Angular 2 Support? HOT 3
- Question: Clean source and layer HOT 3
- How to get information about the line which was clicked? HOT 6
- Map events are not $broadcast inside an $apply HOT 3
- Leaflet Instance HOT 1
- A way to set map dimensions
- Help need to retrieve zoom level HOT 1
- Question: Is there a simple way to get a reference to the underlying map? HOT 3
- click event for custom markers
- How do I get bounds of the current map HOT 1
- Broken Example Link
- Directions control doesn't show path
- Whether to support the mapbox latest version
- Fullscreen button
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-mapboxgl-directive.