Naimikan / angular-mapboxgl-directive

AngularJS directive for Mapbox GL
https://naimikan.github.io/angular-mapboxgl-directive/
MIT License
49 stars 21 forks source link

gl-layers not showing marker on the map #27

Closed st-sathish closed 7 years ago

st-sathish commented 7 years ago

Hello Naimikan, Thanks for your great library. I was trying to load sample json data along with new layer to add a marker on the map but unfortunately, the marker was not showing. The sample data in a non-angular way, It means using map-box script add-layer is working fine. below is the code I was trying.

angular-way: In html:

<mapboxgl 
            gl-style="'mapbox://styles/mapbox/streets-v9'"
            id="<map_id>"
            gl-center="[-77.04, 38.907]"
            gl-min-zoom="11.15"
            gl-max-zoom="18"
            height="height"
            gl-layers="glLayers"
            gl-sources="glSources">
</mapboxgl>

In JS Controller file:

$scope.glSources = [{
                "id": "places",
                "type": "geojson",
                "data": {
                    "type": "FeatureCollection",
                    "features": [{
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Make it Mount Pleasant</strong><p><a href=\"http://www.mtpleasantdc.com/makeitmtpleasant\" target=\"_blank\" title=\"Opens in a new window\">Make it Mount Pleasant</a> is a handmade and vintage market and afternoon of live entertainment and kids activities. 12:00-6:00 p.m.</p>",
                            "icon": "theatre"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.038659, 38.931567]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Mad Men Season Five Finale Watch Party</strong><p>Head to Lounge 201 (201 Massachusetts Avenue NE) Sunday for a <a href=\"http://madmens5finale.eventbrite.com/\" target=\"_blank\" title=\"Opens in a new window\">Mad Men Season Five Finale Watch Party</a>, complete with 60s costume contest, Mad Men trivia, and retro food and drink. 8:00-11:00 p.m. $10 general admission, $20 admission and two hour open bar.</p>",
                            "icon": "theatre"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.003168, 38.894651]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Big Backyard Beach Bash and Wine Fest</strong><p>EatBar (2761 Washington Boulevard Arlington VA) is throwing a <a href=\"http://tallulaeatbar.ticketleap.com/2012beachblanket/\" target=\"_blank\" title=\"Opens in a new window\">Big Backyard Beach Bash and Wine Fest</a> on Saturday, serving up conch fritters, fish tacos and crab sliders, and Red Apron hot dogs. 12:00-3:00 p.m. $25.grill hot dogs.</p>",
                            "icon": "bar"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.090372, 38.881189]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Ballston Arts & Crafts Market</strong><p>The <a href=\"http://ballstonarts-craftsmarket.blogspot.com/\" target=\"_blank\" title=\"Opens in a new window\">Ballston Arts & Crafts Market</a> sets up shop next to the Ballston metro this Saturday for the first of five dates this summer. Nearly 35 artists and crafters will be on hand selling their wares. 10:00-4:00 p.m.</p>",
                            "icon": "art-gallery"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.111561, 38.882342]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Seersucker Bike Ride and Social</strong><p>Feeling dandy? Get fancy, grab your bike, and take part in this year's <a href=\"http://dandiesandquaintrelles.com/2012/04/the-seersucker-social-is-set-for-june-9th-save-the-date-and-start-planning-your-look/\" target=\"_blank\" title=\"Opens in a new window\">Seersucker Social</a> bike ride from Dandies and Quaintrelles. After the ride enjoy a lawn party at Hillwood with jazz, cocktails, paper hat-making, and more. 11:00-7:00 p.m.</p>",
                            "icon": "bicycle"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.052477, 38.943951]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Capital Pride Parade</strong><p>The annual <a href=\"http://www.capitalpride.org/parade\" target=\"_blank\" title=\"Opens in a new window\">Capital Pride Parade</a> makes its way through Dupont this Saturday. 4:30 p.m. Free.</p>",
                            "icon": "star"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.043444, 38.909664]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Muhsinah</strong><p>Jazz-influenced hip hop artist <a href=\"http://www.muhsinah.com\" target=\"_blank\" title=\"Opens in a new window\">Muhsinah</a> plays the <a href=\"http://www.blackcatdc.com\">Black Cat</a> (1811 14th Street NW) tonight with <a href=\"http://www.exitclov.com\" target=\"_blank\" title=\"Opens in a new window\">Exit Clov</a> and <a href=\"http://godsilla.bandcamp.com\" target=\"_blank\" title=\"Opens in a new window\">Gods’illa</a>. 9:00 p.m. $12.</p>",
                            "icon": "music"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.031706, 38.914581]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>A Little Night Music</strong><p>The Arlington Players' production of Stephen Sondheim's  <a href=\"http://www.thearlingtonplayers.org/drupal-6.20/node/4661/show\" target=\"_blank\" title=\"Opens in a new window\"><em>A Little Night Music</em></a> comes to the Kogod Cradle at The Mead Center for American Theater (1101 6th Street SW) this weekend and next. 8:00 p.m.</p>",
                            "icon": "music"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.020945, 38.878241]
                        }
                    }, {
                        "type": "Feature",
                        "properties": {
                            "description": "<strong>Truckeroo</strong><p><a href=\"http://www.truckeroodc.com/www/\" target=\"_blank\">Truckeroo</a> brings dozens of food trucks, live music, and games to half and M Street SE (across from Navy Yard Metro Station) today from 11:00 a.m. to 11:00 p.m.</p>",
                            "icon": "music"
                        },
                        "geometry": {
                            "type": "Point",
                            "coordinates": [-77.007481, 38.876516]
                        }
                    }]
                }
            }];
        $scope.glLayers = [{
            "id": "places",
            "type": "symbol",
            "source":"places",
            "layout": {
                "icon-image": "{icon}-15",
                "icon-allow-overlap": true
            }
        }];

Is there anything am doing wrong? I didn't get any error in the console also.

Naimikan commented 7 years ago

Hi @st-sathish!

Thank you! Which version of directive are you using? I have tried with v0.38.0 and it works fine.

P.D: if you want to see the description field as popup message, you have to do something like:

$scope.glLayers = [
   {
      id: "places",
      type: "symbol",
      source: "places",
      layout: {
         "icon-image": "{icon}-15",
         "icon-allow-overlap": true
      },
      popup: {
         enabled: true,
         onClick: {
               message: "${description}"
         }
      }
   }
];
st-sathish commented 7 years ago

I'm using v0.36.1.

Naimikan commented 7 years ago

Try to use v0.38.0 @st-sathish, I think I fixed that issue in the past.

st-sathish commented 7 years ago

@Naimikan I'll try. Thank you for your quick response :)

st-sathish commented 7 years ago

@Naimikan one quick question. Whether your latest v0.38.0 support previous angular version? Currently, I'm using angular v1.4.7.

Naimikan commented 7 years ago

Hi @st-sathish! Yes, no problem about angular v1.4.7

st-sathish commented 7 years ago

Thank you

Naimikan commented 7 years ago

Hi @st-sathish, it worked?

st-sathish commented 7 years ago

@Naimikan , we already have a code which is not in angular in a separate page using traditional map-box java script code. After a long month our client asked me to develop a new page to integrate map-box for their new requirement without disturbing existing code so I tried your lib to avoid lot of boiler plate. But now they were asking to integrate this functionality to their existing code. so I couldn't able to integrate your code due to continuously delivery me too want to follow the existing code. Sorry for that inconvenience. If I've necessity to integrate angular mapbox I'll use your lib on top and definitely I'll tell the feedback.

Naimikan commented 7 years ago

Oh! ok, don't worry @st-sathish!

Thank you!