enable location
Greetings,
I'm looking into allowing a user to enable their location within the html5 viewer. The thought is that under "I want to" some language indicates "View my location", then their location appears on the map. Can anyone point me in the right direction, or provide some sample code?
Thanks, Matt
-
Hi Matt,
There are plenty of tutorials and examples online regarding Geolocation. It's really quite simple to implement.
Once you have a working piece of Geolocation code, you will probably want to implement it in a command that can be invoked via the I Want To menu. To do so, you can create a custom library and module for the viewer, which is a good option if you are going to do any more custom development in the near future.
The other option is to create the command implementation directly in your HTML page. For example, in Index.html you can add a command implementation underneath the "viewer.initialize()" method like so:
viewer.commandRegistry.command("MyGeolocationCommand").register(viewer, function () {
/* do a Geolocation operation and zoom to the point in the callback (hint: you may have to project it) */
});
Note that this is a convenient way to quickly prototype things without creating a new library, but is not recommended, as the HTML host pages will be overwritten when the viewer is upgraded.
The SDK Samples portion of the HTML5 SDK package contains samples which demonstrate configuration of libraries and modules.
FYI, Version 1.1 of the viewer has a Geolocation button in the UI by default.
Hope this helps!
- Jason
0 -
Jason - thanks. I'll be downloading 1.1 shortly. Hopefully that will get me rolling.
0 -
Sorry, just to clarify: 1.1 is still under active development.
0 -
No problem. I'm eagerly awaiting the release of 1.1
Thanks again, Matt
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
4 kommentarer