HTML Geolocation Element Simplifies Location Access

Many developers still don’t know that HTML now has a <𝗴𝗲𝗼𝗹𝗼𝗰𝗮𝘁𝗶𝗼𝗻> element. Instead of calling this JavaScript API: 𝗻𝗮𝘃𝗶𝗴𝗮𝘁𝗼𝗿.𝗴𝗲𝗼𝗹𝗼𝗰𝗮𝘁𝗶𝗼𝗻.𝗴𝗲𝘁𝗖𝘂𝗿𝗿𝗲𝗻𝘁𝗣𝗼𝘀𝗶𝘁𝗶𝗼𝗻(...) You can now use: <𝗴𝗲𝗼𝗹𝗼𝗰𝗮𝘁𝗶𝗼𝗻 𝗼𝗻𝗹𝗼𝗰𝗮𝘁𝗶𝗼𝗻="𝗵𝗮𝗻𝗱𝗹𝗲𝗟𝗼𝗰𝗮𝘁𝗶𝗼𝗻(𝗲𝘃𝗲𝗻𝘁)" 𝗮𝘂𝘁𝗼𝗹𝗼𝗰𝗮𝘁𝗲></𝗴𝗲𝗼𝗹𝗼𝗰𝗮𝘁𝗶𝗼𝗻> This element was introduced in 𝗖𝗵𝗿𝗼𝗺𝗲 𝟭𝟰𝟰 to simplify how websites request location access. 𝗪𝗵𝘆 𝗶𝘁’𝘀 𝗶𝗻𝘁𝗲𝗿𝗲𝘀𝘁𝗶𝗻𝗴: • Requests are user-initiated instead of random popups • Less JavaScript boilerplate • Easier recovery if users previously blocked location • Built-in event handling for location data This is part of a broader idea of capability-based HTML elements (camera, microphone, etc.). The web platform keeps evolving quietly. Did you know about this element before today? #webdevelopment #javascript #frontend #programming #developers

  • text

As it is currently too limited in browser compatibility I would generally not recommend using right now until the support gets better otherwise you would build two solutions to make it work for everyone, which is kinda bloated.

It looks too perfect to be real! 🤯 What about browser coverage?

No buddy, Recent I integrate API for getting location. Thanks for update 👍🏻

See more comments

To view or add a comment, sign in

Explore content categories