question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Markers do not align to the point.

See original GitHub issue
const sourcePoint =[55.1953125,24.686];
const destPoint = [78.662109375,13.23];

const data =  {
  type: 'Feature',
  geometry: {
    type: 'LineString',
    coordinates: [
      sourcePoint,
      destPoint,
    ]
  }
};

export default class MapBoxMap extends Component {
  constructor(props) {
    super(props);
    this.state = {
      viewport: {
        zoom: 2,
        latitude: sourcePoint[1],
        longitude: sourcePoint[0],
        bearing: 0,
        pitch: 0,
        width: 360,
        height: 360,
        fitBounds:true,
        interactive:false,
      }
    };
  }
  render() {
    const {viewport} = this.state;
    return (

      <MapGL
        style={{ width: '100%', height: '400px' }}
        accessToken={TOKEN}
        onViewportChange={(viewport) => this.setState({ viewport })}
        {...viewport}
      >


        <Source id="route" type="geojson" data={data} />
        <Layer
          id="route"
          type="line"
          source="route"
          layout={{
            'line-join': 'round',
            'line-cap': 'round'
          }}
          paint={{
            'line-color': '#888',
            'line-width': 2
          }}
        />


        <Marker
          latitude={destPoint[1]}
          longitude={destPoint[0]}
        >
          <div>Chennai 👋</div>
        </Marker>

        <Marker
          latitude={sourcePoint[1]}
          longitude={sourcePoint[0]}
        >
          <div>Dubai 👋</div>
        </Marker>
      </MapGL>

image

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JaLe29commented, Jan 23, 2020

@prakashsvmx
I have this issue also after code splitting (using react lazy). Try to include css styles

import 'mapbox-gl/dist/mapbox-gl.css'

0reactions
MicaellyUScommented, Oct 9, 2020

The problem was corrected by making the following changes to index.html:

at the head: <script src="https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.js"></script> <link href="https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css" rel="stylesheet" />

at the body: <script> mapboxgl.accessToken = "INSERT KEY"; var map = new mapboxgl.Map({ container: "map", style: "mapbox://styles/mapbox/streets-v11", // stylesheet location center: [-74.5, 40], // starting position [lng, lat] zoom: 9, // starting zoom }); </script>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Markers and connecting lines between markers not centered ...
One consistent issue I am having is that my markers and lines are not aligned perfectly. Instead, the markers are slightly to the...
Read more >
marker vs. point based chunk alignment - Agisoft Metashape
The alignment using the markers does not seem to position the markers in the same location (within the 3d view of the point...
Read more >
Why Markers points are not aligned with yAxis in Highcharts?
Your data points are plotting events at specific times during those days, and are placed accordingly. This is not weird behavior, it is...
Read more >
Solved: Alignment markers - Autodesk Community - Civil 3D
Select the alignment and choose Edit Alignment Labels. There is a selection in the geometry points label type where you can choose which...
Read more >
Marker based alignment in Agisoft Metashape - YouTube
Learn how to perform a marker based alignment in Agisoft Metashape Pro. Using the align and merge chunk tools in Agisoft allows you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found