Comments (5)
@kalabalik
I had a similar issue, make sure your using rel=stylesheet in your css link as here in this issue..
Also you can see this site I've been testing with:
https://gom-blocks-and-platforms.firebaseapp.com/#!/map
Should be able to inspect the code and see some working examples. There aren't always polygons on there. But if there are they should have working popups.
@Naimikan That being said, I have noticed the "x" to close a popup is no longer working, and if the text is too long or can't wrap seems to throw off the placement of the popup. I think that may be more of the type of data I'm showing.
from angular-mapboxgl-directive.
Hi @kalabalik!
Sorry, I hadn't time for test your issue, but I think that you have to put popup
attribute in $scope.layers
object, like:
$scope.layers = [{
id: "layers",
source: "sources",
type: "fill",
paint: {
"fill-color": "#000000",
"fill-opacity": .4
},
popup: {
enabled: true,
onClick: {
coordinates: [0, 52],
message: "Clicked via GeoJSON!"
}
}
}];
Tell me if it worked!
from angular-mapboxgl-directive.
@LennyZ71 Thanks, but the css was linked correctly.
@Naimikan That was it! Moving the popup
into $scope.layers
did the trick.
Now my only remaining problem is how to make each polygon show a different message in the popup
. How would I reference the properties
in the (many) features inside $scope.sources
from the (one) popup
declaration? In a situation like this:
$scope.sources = {
"id": "sources",
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {
"popupmessage": "Popup text specifically for this popup"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[0, 52],
[0, 53],
[1, 52],
[0, 52]
]
]
}
}]
}
};
$scope.layers = [{
id: "layers",
source: "sources",
type: "fill",
paint: {
"fill-color": "#000000",
"fill-opacity": .4
},
"popup": {
"enabled": true,
"onClick": {
"coordinates": [0, 52],
"message": ? ? ? // here a reference to popupmessage[i] is needed
}
}
}];
I tried popupmessage
, feature.properties.popupmessage
, createMessage(event)
and createMessage($event)
. Every time a not defined error
was thrown (for popupmessage
, feature
, event
and $event
respectively).
Any suggestions how to get the correct message into each popup? Thanks again for your help!
from angular-mapboxgl-directive.
Hi @kalabalik!
Yes, you can do this with:
$scope.layers = [{
id: "layers",
source: "sources",
type: "fill",
paint: {
"fill-color": "#000000",
"fill-opacity": .4
},
"popup": {
"enabled": true,
"onClick": {
"coordinates": [0, 52],
"message": '{$popupmessage}'
}
}
}];
Tell me it it worked! (Sorry, I have to update the wiki)
from angular-mapboxgl-directive.
'${popupmessage}'
(dollar sign outside the curly brackets) worked for me.
Thank you very much for your straightforward help and patience with me!
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.