Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw a line between two markers react-native? #6

Closed
ElangoPrince opened this issue Feb 11, 2024 · 7 comments
Closed

Draw a line between two markers react-native? #6

ElangoPrince opened this issue Feb 11, 2024 · 7 comments

Comments

@ElangoPrince
Copy link

ElangoPrince commented Feb 11, 2024

How to draw poly lines between two markers in mappls-map-react-native. I tried but not visible.

let route = {
    	"type": "FeatureCollection",
    	"features": [
          {
            	"type": "Feature",
            	"properties": {},
            	"geometry": {
              	"type": "LineString",
          		"coordinates": [
            			[
              			     19.2052853,
              			     72.8708257
            			],
            			[
              			     12.991463333333334,
              			     77.70299666666666
            			]
          		]
            	}
          }
    	]
  }
<MapplsGL.MapView
      style={{flex: 1}}
      zoomEnabled={true}
      onPress={event => console.log('event', event)}>
      <MapplsGL.Camera
       ref={c  => (this.camera = c)}
          zoomLevel={13}
          animationMode="easeTo"
          centerCoordinate={[long, lat]}
      />
      <MapplsGL.ShapeSource id='line1' shape={route}>
             <MapplsGL.LineLayer id='linelayer1' style={{lineColor:'#ff0000'}} />
     </MapplsGL.ShapeSource>
     <MapplsGL.UserLocation visible={true}></MapplsGL.UserLocation>
</MapplsGL.MapView>
@ElangoPrince
Copy link
Author

@Saksham66 @spacekingindia @mamtasharma117 Can you anyone help me on it.

@Saksham66
Copy link
Collaborator

Please, set the lineWidth in the style

@ElangoPrince
Copy link
Author

ElangoPrince commented Mar 26, 2024

@Saksham66 I tried that. But still line not visible.

<MapplsGL.ShapeSource id='line1' shape={route}>
   	<MapplsGL.LineLayer id='linelayer1' style={
   	 {
   	         lineColor: 'red',
   	         lineWidth: 2,
   	         lineOpacity: 1
   	 }
   	} />
</MapplsGL.ShapeSource>

@Saksham66
Copy link
Collaborator

@ElangoPrince You are passing incorrect latitude and longitude in the feature, in the coordinate array first is longitude and second is latitude


let route = {
    	"type": "FeatureCollection",
    	"features": [
          {
            	"type": "Feature",
            	"properties": {},
            	"geometry": {
              	"type": "LineString",
          		"coordinates": [
            			[
              			     72.8708257,
              			     19.2052853
            			],
            			[
                                       77.70299666666666,
              			     12.991463333333334
            			]
          		]
            	}
          }
    	]
  }

@ElangoPrince
Copy link
Author

@Saksham66 Great. It was working fine now. If there any way to show routes between markers? Instead of line. Because, shows like straight line between markers.

@Saksham66
Copy link
Collaborator

For that you need to use Routing API:
https://github.com/mappls-api/mappls-react-native-sdk/blob/main/docs/v1.0.2/Routing-Api.md

This will gives you routes polyline you can also refer the sample:
https://github.com/mappls-api/mappls-react-native-sdk/blob/main/src/scenes/GetDirection.js

@ElangoPrince
Copy link
Author

@Saksham66 @spacekingindia The current SDK version is com.mappls.sdk:mappls-android-sdk:8.0.7. Is that possible to update latest SDK version? ie: 8.1.x?
Because, 8.0.7 facing some issues in touches. Ie: com.facebook.react.bridge.ReactNoCrashSoftException: Cannot find EventEmitter for receivedTouches App getting closed suddenly in sometime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants