How to use the mapbox-gl.Marker function in mapbox-gl

To help you get started, we’ve selected a few mapbox-gl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pbeshai / deckgl-point-animation / src / demo_ScatterplotLayer.js View on Github external
onClick(evt) {
      // add a marker on the map wherever you clicked
      new mapboxgl.Marker().setLngLat(evt.lngLat).addTo(map);
      console.log('clicked at', evt.lngLat);
    },
github WarsawLO / warsawlo / src / templates / School.js View on Github external
center: [location.position.Longitude, location.position.Latitude],
        zoom: 13,
      })
      let el = document.createElement('div')
      el.className = 'marker'
      el.style = 'display:inline-block;'
      ReactDOM.render((
        
          
        
      ), el)
      this.map.addControl(new mapboxgl.NavigationControl(), 'top-left')
      this.map.addControl(new mapboxgl.FullscreenControl({ container: document.querySelector('body') }))
      this.map.on('mousemove', this.handleMouseStart)
      this.map.on('mouseout', this.handleMouseOut)
      new mapboxgl.Marker(el)
        .setLngLat([location.position.Longitude, location.position.Latitude])
        .addTo(this.map)
      console.log(this.fixedHeaderEl.current.clientHeight)
      this.setState({
        headerHeight: this.fixedHeaderEl.current.clientHeight,
      })
    }

    (function(d, s, id) {
      // if(!document.querySelector('#moovit-jsw')){
      let js, fjs = d.getElementsByTagName(s)[0]
      js = d.createElement(s)
      js.id = id
      js.src = 'https://widgets.moovit.com/wtp/pl'
      fjs.parentNode.insertBefore(js, fjs)
      // }
github deltachat / deltachat-desktop / src / renderer / components / map / MapComponent.js View on Github external
poiMarker.map((location) => {
          var el = document.createElement('div')
          el.className = 'marker-icon'
          el.innerHTML = location.marker
          // make a marker for each feature and add to the map
          const m = new mapboxgl.Marker(el)
            .setLngLat([location.longitude, location.latitude])
            .addTo(this.map)
          m.location = location
        })
      }
github Wykks / ngx-mapbox-gl / src / app / lib / marker / marker.component.ts View on Github external
ngAfterViewInit() {
    this.markerInstance = new Marker(this.content.nativeElement, { offset: this.offset });
    this.markerInstance.setLngLat(this.feature ? this.feature.geometry!.coordinates : this.lngLat!);
    this.MapService.mapCreated$.subscribe(() => {
      this.MapService.addMarker(this.markerInstance!);
    });
  }
github Bluegrass-Grief-Owls / coordin-eat / client / components / TripDirections.jsx View on Github external
function markerFactory(name, long, lat, img, map){
			let markerDomEl = document.createElement('div')
			markerDomEl.className = 'mapMarker'
			markerDomEl.name = name
			markerDomEl.style.backgroundImage = img

			new mapboxgl.Marker(markerDomEl)
				.setLngLat([long, lat + 0.001])
				.setPopup(new mapboxgl.Popup({ offset: 25 })
					.setHTML('<h5>' + markerDomEl.name + '</h5>'))
				.addTo(map)
		}
		markerFactory(this.meetingPlace.name, this.meetingPlace.coordinates.longitude, this.meetingPlace.coordinates.latitude, 'url(../DestPin.png)', this.map)
github DoFabien / OsmGo / src / app / services / map.service.ts View on Github external
createDomMoveMarker(coord: number[], data) {
    const el = document.createElement('div');
    el.className = 'moveMarkerIcon';
    const marker = new mapboxgl.Marker(el, { offset: [0, -15] }).setLngLat(coord);
    marker.data = data;
    return marker;
  }
github salvozappa / mapkeep / frontend / src / components / Map.js View on Github external
renderPositionMarker(geolocation) {
        if (this.renderedPositionMarker !== null) {
            this.renderedPositionMarker.remove();
        }
        const htmlElement = document.createElement('div');
        htmlElement.id = 'geolocation-marker';
        this.renderedPositionMarker = new MapboxGL.Marker({ element: htmlElement });
        this.renderedPositionMarker.setLngLat([geolocation.longitude, geolocation.latitude]);
        this.renderedPositionMarker.addTo(this.mapbox);
    }
github magma / magma / nms / fbcnms-projects / magmalte / app / components / insights / GatewayMapMarker.js View on Github external
addMarker() {
    const {feature, map} = this.props;

    const markerEl = document.createElement('div');
    ReactDOM.render(this.renderMarker(), markerEl);

    const popupEl = document.createElement('div');
    ReactDOM.render(
      ,
      popupEl,
    );

    const popup = new mapboxgl.Popup({offset: 50}).setDOMContent(popupEl);

    const marker = new mapboxgl.Marker({
      element: markerEl,
      offset: [0, -30],
    })
      .setLngLat(this._featureLngLat())
      .setPopup(popup)
      .addTo(map);

    this.setState({marker});
  }
github magma / magma / symphony / app / fbcnms-packages / fbcnms-ui / insights / GatewayMapMarker.js View on Github external
addMarker() {
    const {feature, map} = this.props;

    const markerEl = document.createElement('div');
    ReactDOM.render(this.renderMarker(), markerEl);

    const popupEl = document.createElement('div');
    ReactDOM.render(
      ,
      popupEl,
    );

    const popup = new mapboxgl.Popup({offset: 50}).setDOMContent(popupEl);

    const marker = new mapboxgl.Marker({
      element: markerEl,
      offset: [0, -30],
    })
      .setLngLat(this._featureLngLat())
      .setPopup(popup)
      .addTo(map);

    this.setState({marker});
  }