Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- // Define your product name and version
- tomtom.setProductInfo('MapsWebSDKExamplesSelfhosted',
- '4.47.2-SNAPSHOT');
- var map, marker;
- // Setting TomTom keys
- tomtom.key('D5IYmsgLaSB7BkLe9jgyhDA923FgG0mS');
- tomtom.searchKey('D5IYmsgLaSB7BkLe9jgyhDA923FgG0mS');
- //Creating the map
- map = tomtom
- .map('map', {
- source : 'vector',
- basePath : '/sdk'
- })
- .setView(
- [
- "${requestScope.results.get(0).getPosition().getLat()}",
- "${requestScope.results.get(0).getPosition().getLon()}" ],
- 14);
- // Adding marker to the map
- marker = tomtom.L
- .marker(
- [
- "${requestScope.results.get(0).getPosition().getLat()}",
- "${requestScope.results.get(0).getPosition().getLon()}" ],
- {
- draggable : true
- }).bindPopup('Amsterdam').addTo(map);
- // Show popup each time the marker is moved
- marker
- .on(
- 'dragend',
- function(e) {
- tomtom
- .reverseGeocode(
- {
- position : e.target
- .getLatLng()
- })
- .go(
- function(response) {
- if (response
- && response.address
- && response.address.freeformAddress) {
- marker
- .setPopupContent(response.address.freeformAddress);
- } else {
- marker
- .setPopupContent('No results found');
- }
- marker.openPopup();
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement