-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow using elements in logo attribution options
This commit lets the user use an element object instead of a {src: href} object for an attribution logo when creating a map. This opens a lot of possibilities for that logo, for example setting the target to force the logo to open in a new tab when clicked.
- Loading branch information
1 parent
ed6ac93
commit 3a1ff59
Showing
5 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
layout: example.html | ||
title: Custom Icon | ||
shortdesc: Example using a custom attribution icon object | ||
docs: > | ||
This example creates a custom element for the attribution icon | ||
tags: "icon, element" | ||
--- | ||
<div id="map" class="map"><div id="popup"></div></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
goog.require('ol.Map'); | ||
goog.require('ol.View'); | ||
goog.require('ol.layer.Tile'); | ||
goog.require('ol.source.OSM'); | ||
|
||
var logoElement = document.createElement('a'); | ||
logoElement.href = 'http://www.osgeo.org/'; | ||
logoElement.target = '_blank'; | ||
|
||
var logoImage = new Image(); | ||
logoImage.src = 'http://www.osgeo.org/sites/all/themes/osgeo/logo.png'; | ||
|
||
logoElement.appendChild(logoImage); | ||
|
||
var map = new ol.Map({ | ||
layers: [ | ||
new ol.layer.Tile({ | ||
source: new ol.source.OSM() | ||
}) | ||
], | ||
target: 'map', | ||
view: new ol.View({ | ||
center: [0, 0], | ||
zoom: 2 | ||
}), | ||
logo: logoElement | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters