Giter Club home page Giter Club logo

Comments (6)

Naimikan avatar Naimikan commented on May 30, 2024

Hi @mm-ns! Thank you very much for use my directive.

I have to complete the documentation. You can create markers using glSources and glLayers directives.

$scope.glSources = [
   {
      id: 'markers',
      type: 'geojson',
      data: {
         type: 'FeatureCollection',
         features: [
            {
               type: 'Feature',
               geometry: {
                  type: 'Point',
                  coordinates: [12.584943, 55.681505]
               }
            }, {
               type: 'Feature',
               geometry: {
                  type: 'Point',
                  coordinates: [12.584589, 55.681599]
               }
            }
         ]
      }
   }
];

$scope.glLayers = [
   {
      id: 'markers',
      type: 'circle',
      source: 'markers',
      paint: {
         'circle-radius': 8,
         'circle-color': '#FF620D'
      }
   }
];
<mapboxgl
   track-resize="true"
   gl-controls="glControls"
   gl-zoom="mapParam.zoom"
   gl-style="mapParam.style"
   gl-center="mapParam.center"
   gl-sources="glSources"
   gl-layers="glLayers"
   ng-if="mapHasLoaded">
</mapboxgl>

Tell me if this worked!

from angular-mapboxgl-directive.

mm-ns avatar mm-ns commented on May 30, 2024

Hi there!

That's actually what I ended up doing xD Thanks!

from angular-mapboxgl-directive.

mm-ns avatar mm-ns commented on May 30, 2024

Can this method be used adding custom markers / icons / images?

from angular-mapboxgl-directive.

Naimikan avatar Naimikan commented on May 30, 2024

Hi!

You can use glMarkers directive like:

function createElement () {
   var element = document.createElement('div');
   element.style.backgroundImage = 'url(<YOUR_IMAGE>)';

  return element;
}

$scope.glMarkers = [
   {
      coordinates: [12.584943, 55.681505],
      element: createElement()
   }, {
      coordinates: [12.584589, 55.681599],
      element: createElement()
   }
];
<mapboxgl
   track-resize="true"
   gl-controls="glControls"
   gl-zoom="mapParam.zoom"
   gl-style="mapParam.style"
   gl-center="mapParam.center"
   gl-markers="glMarkers"
   ng-if="mapHasLoaded">
</mapboxgl>

from angular-mapboxgl-directive.

mm-ns avatar mm-ns commented on May 30, 2024

Cool, Thanks! Appreciate it!

Do you know by any chance if there is any benefit using one method over the other one? Is geojson more performant?

from angular-mapboxgl-directive.

Naimikan avatar Naimikan commented on May 30, 2024

I dont know if there are any benefits using markers or geojson.
Using markers, you are putting an HTMLElement inside a map canvas, and using geojson, you are drawing on the map.

I hope I've helped.

from angular-mapboxgl-directive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.