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.

Can't press ShapeSource on top of UserLocation

See original GitHub issue

Hello,

image

I have a SymbolLayer located underneath the UserLocation, and I wish the SymbolLayer to be pressable. But it seems it can’t be done: when I press the icon, it is actually the UserLocation which is pressed, and the UserLocation onPress event doesn’t have any argument and doesn’t have a pointerEvents prop or equivalent.

Is there a way to get to the SymbolLayer ?

Again, great repo, and greater to become, thanks all for the work done !

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
arnaudambrocommented, Oct 24, 2019

Alright, with a proper utilisation of belowLayerID and aboveLayerId, I got this working. SUppose your SymbolLayer within your ShapeSource has an id of markersSymbol, here is the code I used for the UserLocation

import React from 'react';
import MapboxGL from '@react-native-mapbox-gl/maps';
import { withTheme } from 'styled-components';

const layerStyles = (circleColor) => ({
  pluse: {
    circleRadius: 15,
    circleColor,
    circleOpacity: 0.2,
    circlePitchAlignment: 'map',
  },
  background: {
    circleRadius: 9,
    circleColor: '#fff',
    circlePitchAlignment: 'map',
  },
  foreground: {
    circleRadius: 6,
    circleColor,
    circlePitchAlignment: 'map',
  },
});


const MyUserLocation = ({ theme: { color: { primary } } }) =>
  <MapboxGL.UserLocation
    visible
    animated
  >
    <MapboxGL.CircleLayer
      key="mapboxUserLocationPluseCircle"
      id="mapboxUserLocationPluseCircle"
      belowLayerID='markersSymbol'
      style={layerStyles(primary).pluse}
    />
    <MapboxGL.CircleLayer
      key="mapboxUserLocationWhiteCircle"
      id="mapboxUserLocationWhiteCircle"
      belowLayerID='markersSymbol'
      style={layerStyles(primary).background}
    />
    <MapboxGL.CircleLayer
      key="mapboxUserLocationBlueCicle"
      id="mapboxUserLocationBlueCicle"
      belowLayerID='markersSymbol'
      aboveLayerID="mapboxUserLocationWhiteCircle"
      style={layerStyles(primary).foreground}
    />
  </MapboxGL.UserLocation>

export default withTheme(MyUserLocation)
4reactions
lpfundingcommented, Oct 15, 2019

@kristfal I don’t think this is a narrow usecase… If anyone has custom markers rendered (think of the earthquake example) which are clickable, none can be clicked if they are within a 1inch by 1inch square of UserLocation…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use user press as Feature for MapboxGL ShapeSource?
I created a React Native functional component and try to create a new point at the position where the user presses:
Read more >
rnmapbox/Lobby - Gitter
Right now I'm using a ShapeSource that has a child CircleLayer . The ShapeSource has a geometry created by using the point function...
Read more >
mapbox - Bountysource
This will enable users to place custom views on top of the map with some built ... to ShapeSource with specific icon and...
Read more >
Namespace Telerik.Windows.Controls.Map - API Reference
2-way binding can't be specified. ExtendedDataProvider ... Determines where to place Label on top of the element or between two of them. LabelLocationMode....
Read more >
expo you may need an appropriate loader to handle this file ...
Top Answer. Next. Answered on Oct 25, 2019. The issue is webpack doesn't understand React's JSX syntax so it's unable to handle this...
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