Openlayers: feature.get returns the attributes path2019 Community Moderator ElectionOpenLayers vs Google Maps?event.preventDefault() vs. return falseReturn multiple values in JavaScript?Javascript: Close Popup, Open New Window & RedirectHow to get the data-id attribute?Why does ++[[]][+[]]+[+[]] return the string “10”?How do I return the response from an asynchronous call?Android WebView: Determine <a> target= “_ blank”Href vs select boxThe relative path in Vue single file components does not work properly
Insult for someone who "doesn't know anything"
If nine coins are tossed, what is the probability that the number of heads is even?
PTIJ: Sport in the Torah
Issue with units for a rocket nozzle throat area problem
How spaceships determine each other's mass in space?
Why isn't P and P/poly trivially the same?
Should I apply for my boss's promotion?
Why is there an extra space when I type "ls" on the Desktop?
Propulsion Systems
How to distinguish easily different soldier of ww2?
I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?
Help! My Character is too much for her story!
What does *dead* mean in *What do you mean, dead?*?
Does the US political system, in principle, allow for a no-party system?
What can I do if someone tampers with my SSH public key?
How can I have x-axis ticks that show ticks scaled in powers of ten?
Should I file my taxes? No income, unemployed, but paid 2k in student loan interest
Generating a list with duplicate entries
Create chunks from an array
Cycles on the torus
Can inspiration allow the Rogue to make a Sneak Attack?
How to make sure I'm assertive enough in contact with subordinates?
Is the differential, dp, exact or not?
Sort array by month and year
Openlayers: feature.get returns the attributes path
2019 Community Moderator ElectionOpenLayers vs Google Maps?event.preventDefault() vs. return falseReturn multiple values in JavaScript?Javascript: Close Popup, Open New Window & RedirectHow to get the data-id attribute?Why does ++[[]][+[]]+[+[]] return the string “10”?How do I return the response from an asynchronous call?Android WebView: Determine <a> target= “_ blank”Href vs select boxThe relative path in Vue single file components does not work properly
I have an openlayers map with a point layer that on click on a feature opens a popup. Inside the popup I show a clickable link that is supposed to lead to a url that is stored inside the attribute table of the layer.
But if I click the layer a link opens to a path like "C:/Users/user/.../URL". The URL is all I want to have, but the browser also opens the path to where the project is saved.
My code:
map.on('click', function(event)
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).attr('data-content', '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>');
$(elementPopup).popover('placement': 'top', 'html': true);
$(elementPopup).popover('show');
document.getElementById('link').href = feature.get('KATASTER')
else
$(elementPopup).popover('html': true);
$(elementPopup).popover('hide');
);
If I substitute '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>'
for feature.get('KATASTER')
the correct link appears (but since since it is not inside the statement it is not clickable).
javascript openlayers
add a comment |
I have an openlayers map with a point layer that on click on a feature opens a popup. Inside the popup I show a clickable link that is supposed to lead to a url that is stored inside the attribute table of the layer.
But if I click the layer a link opens to a path like "C:/Users/user/.../URL". The URL is all I want to have, but the browser also opens the path to where the project is saved.
My code:
map.on('click', function(event)
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).attr('data-content', '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>');
$(elementPopup).popover('placement': 'top', 'html': true);
$(elementPopup).popover('show');
document.getElementById('link').href = feature.get('KATASTER')
else
$(elementPopup).popover('html': true);
$(elementPopup).popover('hide');
);
If I substitute '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>'
for feature.get('KATASTER')
the correct link appears (but since since it is not inside the statement it is not clickable).
javascript openlayers
add a comment |
I have an openlayers map with a point layer that on click on a feature opens a popup. Inside the popup I show a clickable link that is supposed to lead to a url that is stored inside the attribute table of the layer.
But if I click the layer a link opens to a path like "C:/Users/user/.../URL". The URL is all I want to have, but the browser also opens the path to where the project is saved.
My code:
map.on('click', function(event)
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).attr('data-content', '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>');
$(elementPopup).popover('placement': 'top', 'html': true);
$(elementPopup).popover('show');
document.getElementById('link').href = feature.get('KATASTER')
else
$(elementPopup).popover('html': true);
$(elementPopup).popover('hide');
);
If I substitute '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>'
for feature.get('KATASTER')
the correct link appears (but since since it is not inside the statement it is not clickable).
javascript openlayers
I have an openlayers map with a point layer that on click on a feature opens a popup. Inside the popup I show a clickable link that is supposed to lead to a url that is stored inside the attribute table of the layer.
But if I click the layer a link opens to a path like "C:/Users/user/.../URL". The URL is all I want to have, but the browser also opens the path to where the project is saved.
My code:
map.on('click', function(event)
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).attr('data-content', '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>');
$(elementPopup).popover('placement': 'top', 'html': true);
$(elementPopup).popover('show');
document.getElementById('link').href = feature.get('KATASTER')
else
$(elementPopup).popover('html': true);
$(elementPopup).popover('hide');
);
If I substitute '<a id="link" target="_blank" rel="noopener noreferrer">Link</a>'
for feature.get('KATASTER')
the correct link appears (but since since it is not inside the statement it is not clickable).
javascript openlayers
javascript openlayers
asked 2 days ago
gHupfgHupf
1105
1105
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
What about intializing the popever with the content
option, instead updating only the link?
map.on('click', function(event) {
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
// Always hide the popover
$(elementPopup).popover('hide');
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).popover(
placement: 'top',
animation: false,
html: true,
trigger: 'focus',
title: "",
content: '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" href="'+feature.get('KATASTER')+'" rel="noopener noreferrer">Link</a>'
);
);
I didn't know about the content option yet, thats definetly a cleaner way to do it, thanks! But still, I get the same as before: Not the url appears in the new browser window, but the path to the project with the url appended shows up.
– gHupf
2 days ago
1
ups. i didn't get the question then. what's insidefeature.get('KATASTER')
then?
– GiuServ
2 days ago
I have a layer with an attribute called KATASTER and the KATASTER holds a link for each feature. So with thefeature.get('KATASTER')
request I am supposed to get back a link. But what I get is the path where the code is saved with the url appended like "C:/Users/user/.../URL", if the project is saved in "C:/Users/user/...". I don't have the problem if I just usefeature.get('KATASTER')
without the<a href ...>
. I just get the unclickable url, but I need a clickable one. I was probably unclear in my question. Is it clear now?
– gHupf
2 days ago
so if you print out the firstfeature.get('KATASTER')
what are you getting? if it'sC:/Users/user/.../URL
the problema is where you're assigningKATASTER
, so that's why will be usefull to see your feature declaration to find out the problem.
– GiuServ
2 days ago
1
The url starts with ´www´ and that seems to be the problem. If I add ´http://´ everything works fine. I see that it is needed, so the browser recognizes the string as an url.
– gHupf
20 hours ago
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023339%2fopenlayers-feature-get-returns-the-attributes-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
What about intializing the popever with the content
option, instead updating only the link?
map.on('click', function(event) {
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
// Always hide the popover
$(elementPopup).popover('hide');
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).popover(
placement: 'top',
animation: false,
html: true,
trigger: 'focus',
title: "",
content: '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" href="'+feature.get('KATASTER')+'" rel="noopener noreferrer">Link</a>'
);
);
I didn't know about the content option yet, thats definetly a cleaner way to do it, thanks! But still, I get the same as before: Not the url appears in the new browser window, but the path to the project with the url appended shows up.
– gHupf
2 days ago
1
ups. i didn't get the question then. what's insidefeature.get('KATASTER')
then?
– GiuServ
2 days ago
I have a layer with an attribute called KATASTER and the KATASTER holds a link for each feature. So with thefeature.get('KATASTER')
request I am supposed to get back a link. But what I get is the path where the code is saved with the url appended like "C:/Users/user/.../URL", if the project is saved in "C:/Users/user/...". I don't have the problem if I just usefeature.get('KATASTER')
without the<a href ...>
. I just get the unclickable url, but I need a clickable one. I was probably unclear in my question. Is it clear now?
– gHupf
2 days ago
so if you print out the firstfeature.get('KATASTER')
what are you getting? if it'sC:/Users/user/.../URL
the problema is where you're assigningKATASTER
, so that's why will be usefull to see your feature declaration to find out the problem.
– GiuServ
2 days ago
1
The url starts with ´www´ and that seems to be the problem. If I add ´http://´ everything works fine. I see that it is needed, so the browser recognizes the string as an url.
– gHupf
20 hours ago
|
show 2 more comments
What about intializing the popever with the content
option, instead updating only the link?
map.on('click', function(event) {
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
// Always hide the popover
$(elementPopup).popover('hide');
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).popover(
placement: 'top',
animation: false,
html: true,
trigger: 'focus',
title: "",
content: '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" href="'+feature.get('KATASTER')+'" rel="noopener noreferrer">Link</a>'
);
);
I didn't know about the content option yet, thats definetly a cleaner way to do it, thanks! But still, I get the same as before: Not the url appears in the new browser window, but the path to the project with the url appended shows up.
– gHupf
2 days ago
1
ups. i didn't get the question then. what's insidefeature.get('KATASTER')
then?
– GiuServ
2 days ago
I have a layer with an attribute called KATASTER and the KATASTER holds a link for each feature. So with thefeature.get('KATASTER')
request I am supposed to get back a link. But what I get is the path where the code is saved with the url appended like "C:/Users/user/.../URL", if the project is saved in "C:/Users/user/...". I don't have the problem if I just usefeature.get('KATASTER')
without the<a href ...>
. I just get the unclickable url, but I need a clickable one. I was probably unclear in my question. Is it clear now?
– gHupf
2 days ago
so if you print out the firstfeature.get('KATASTER')
what are you getting? if it'sC:/Users/user/.../URL
the problema is where you're assigningKATASTER
, so that's why will be usefull to see your feature declaration to find out the problem.
– GiuServ
2 days ago
1
The url starts with ´www´ and that seems to be the problem. If I add ´http://´ everything works fine. I see that it is needed, so the browser recognizes the string as an url.
– gHupf
20 hours ago
|
show 2 more comments
What about intializing the popever with the content
option, instead updating only the link?
map.on('click', function(event) {
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
// Always hide the popover
$(elementPopup).popover('hide');
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).popover(
placement: 'top',
animation: false,
html: true,
trigger: 'focus',
title: "",
content: '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" href="'+feature.get('KATASTER')+'" rel="noopener noreferrer">Link</a>'
);
);
What about intializing the popever with the content
option, instead updating only the link?
map.on('click', function(event) {
var feature = map.forEachFeatureAtPixel(event.pixel, function(feature, layer)
if (layer === knoten)
return feature;
);
// Always hide the popover
$(elementPopup).popover('hide');
if (feature != null)
var pixel = event.pixel;
var coord = map.getCoordinateFromPixel(pixel);
popup.setPosition(coord);
$(elementPopup).popover(
placement: 'top',
animation: false,
html: true,
trigger: 'focus',
title: "",
content: '<b>1: </b>' + ' ' + feature.get('ERHEB_NR') +
'</br><b>2: </b>' + '   ' + '<a id="link" target="_blank" href="'+feature.get('KATASTER')+'" rel="noopener noreferrer">Link</a>'
);
);
answered 2 days ago
GiuServGiuServ
8381423
8381423
I didn't know about the content option yet, thats definetly a cleaner way to do it, thanks! But still, I get the same as before: Not the url appears in the new browser window, but the path to the project with the url appended shows up.
– gHupf
2 days ago
1
ups. i didn't get the question then. what's insidefeature.get('KATASTER')
then?
– GiuServ
2 days ago
I have a layer with an attribute called KATASTER and the KATASTER holds a link for each feature. So with thefeature.get('KATASTER')
request I am supposed to get back a link. But what I get is the path where the code is saved with the url appended like "C:/Users/user/.../URL", if the project is saved in "C:/Users/user/...". I don't have the problem if I just usefeature.get('KATASTER')
without the<a href ...>
. I just get the unclickable url, but I need a clickable one. I was probably unclear in my question. Is it clear now?
– gHupf
2 days ago
so if you print out the firstfeature.get('KATASTER')
what are you getting? if it'sC:/Users/user/.../URL
the problema is where you're assigningKATASTER
, so that's why will be usefull to see your feature declaration to find out the problem.
– GiuServ
2 days ago
1
The url starts with ´www´ and that seems to be the problem. If I add ´http://´ everything works fine. I see that it is needed, so the browser recognizes the string as an url.
– gHupf
20 hours ago
|
show 2 more comments
I didn't know about the content option yet, thats definetly a cleaner way to do it, thanks! But still, I get the same as before: Not the url appears in the new browser window, but the path to the project with the url appended shows up.
– gHupf
2 days ago
1
ups. i didn't get the question then. what's insidefeature.get('KATASTER')
then?
– GiuServ
2 days ago
I have a layer with an attribute called KATASTER and the KATASTER holds a link for each feature. So with thefeature.get('KATASTER')
request I am supposed to get back a link. But what I get is the path where the code is saved with the url appended like "C:/Users/user/.../URL", if the project is saved in "C:/Users/user/...". I don't have the problem if I just usefeature.get('KATASTER')
without the<a href ...>
. I just get the unclickable url, but I need a clickable one. I was probably unclear in my question. Is it clear now?
– gHupf
2 days ago
so if you print out the firstfeature.get('KATASTER')
what are you getting? if it'sC:/Users/user/.../URL
the problema is where you're assigningKATASTER
, so that's why will be usefull to see your feature declaration to find out the problem.
– GiuServ
2 days ago
1
The url starts with ´www´ and that seems to be the problem. If I add ´http://´ everything works fine. I see that it is needed, so the browser recognizes the string as an url.
– gHupf
20 hours ago
I didn't know about the content option yet, thats definetly a cleaner way to do it, thanks! But still, I get the same as before: Not the url appears in the new browser window, but the path to the project with the url appended shows up.
– gHupf
2 days ago
I didn't know about the content option yet, thats definetly a cleaner way to do it, thanks! But still, I get the same as before: Not the url appears in the new browser window, but the path to the project with the url appended shows up.
– gHupf
2 days ago
1
1
ups. i didn't get the question then. what's inside
feature.get('KATASTER')
then?– GiuServ
2 days ago
ups. i didn't get the question then. what's inside
feature.get('KATASTER')
then?– GiuServ
2 days ago
I have a layer with an attribute called KATASTER and the KATASTER holds a link for each feature. So with the
feature.get('KATASTER')
request I am supposed to get back a link. But what I get is the path where the code is saved with the url appended like "C:/Users/user/.../URL", if the project is saved in "C:/Users/user/...". I don't have the problem if I just use feature.get('KATASTER')
without the <a href ...>
. I just get the unclickable url, but I need a clickable one. I was probably unclear in my question. Is it clear now?– gHupf
2 days ago
I have a layer with an attribute called KATASTER and the KATASTER holds a link for each feature. So with the
feature.get('KATASTER')
request I am supposed to get back a link. But what I get is the path where the code is saved with the url appended like "C:/Users/user/.../URL", if the project is saved in "C:/Users/user/...". I don't have the problem if I just use feature.get('KATASTER')
without the <a href ...>
. I just get the unclickable url, but I need a clickable one. I was probably unclear in my question. Is it clear now?– gHupf
2 days ago
so if you print out the first
feature.get('KATASTER')
what are you getting? if it's C:/Users/user/.../URL
the problema is where you're assigning KATASTER
, so that's why will be usefull to see your feature declaration to find out the problem.– GiuServ
2 days ago
so if you print out the first
feature.get('KATASTER')
what are you getting? if it's C:/Users/user/.../URL
the problema is where you're assigning KATASTER
, so that's why will be usefull to see your feature declaration to find out the problem.– GiuServ
2 days ago
1
1
The url starts with ´www´ and that seems to be the problem. If I add ´http://´ everything works fine. I see that it is needed, so the browser recognizes the string as an url.
– gHupf
20 hours ago
The url starts with ´www´ and that seems to be the problem. If I add ´http://´ everything works fine. I see that it is needed, so the browser recognizes the string as an url.
– gHupf
20 hours ago
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55023339%2fopenlayers-feature-get-returns-the-attributes-path%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown