mariusandra / pigeon-maps

ReactJS Maps without external dependencies
https://pigeon-maps.js.org/
MIT License
3.43k stars 142 forks source link

Suggestion: convert the center/marker input coords to numbers #171

Open bnbon opened 1 year ago

bnbon commented 1 year ago

Hello,

Great component, just realised what my final bug was – the values passed in were strings; so now I just appended a + to the values, but seems fair to suggest that the component should convert strings to numbers anyway

My fix was:

  const [center, setCenter] = useState([+lat, +lon]);
  const [marker] = useState([+lat, +lon]);
hydrandt commented 1 year ago

Thanks for this bugreport. Indeed, passing latitude and longitude to the Map component as center or defaultCenter as string, the map moves to the expected coordinates, giving you the feeling that everything's fine. But the Marker component doesn't deal with this and silently does nothing.

So, if you are facing this issue, doublecheck that you're passing [Number, Number] to the Marker component as the anchor prop:)