-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Can't addOverlay #1
Comments
Could you share a jsfiddle or some other sort of live example? |
I've updated the example repo to show adding an overlay and responding to clicks on features. It works fine for me with an image marker. The relevant part is here: export default class Example extends React.Component {
constructor( props ) {
super( props );
this.map = React.createRef();
}
componentDidMount() {
// Once map is initialized add an overlay
const map = this.map.current;
map.addOverlay( overlay );
}
render() {
return React.createElement( ProceduralMap, {
ref: this.map,
datasource,
// Configure UI elements to show
compassVisible: true,
// Configure initial map location
displayLocation: {
latitude: 47.25,
longitude: 13.56
},
// Define callbacks
onFeatureClicked: id => {
// The id passed here is defined in the overlay
const map = this.map.current;
// Simply focus on the feature when clicked
map.focusOnFeature( id );
}
} );
}
} As to your other point, the onOverlayAdded etc functions are missing because you haven't defined them. They are callbacks that you define on the map component. If they are not defined then it is expected that they will not be present and thus they won't get called. Again, see the above example to see how to define these. |
Hum...strange, I'm using React with hooks. I'm unable to get the same results:
I can see the maps, but no added custom overlay. This same approach works with the basic line however. |
Without seeing what you have in |
Sorry, I'm using the exact same overlay.js file you have here: https://github.com/felixpalmer/procedural-gl-react-example/blob/main/overlay.js |
Ok, so I found a solution, but I think this should be included on documentation or the component itself. The font awesome css was missing on my index.html
|
Hi,
Using create-react-app with hooks. Map loads well, but calling addOverlay doesn't seem to work. The blue-fot.png is on public folder root.
The text was updated successfully, but these errors were encountered: