|
I would like to add a marker to the map using the form. Can anyone help me? Installing the map works. I want to display markers after entering x and y, and read this data from the table. I have 2 inputs, one for X and the other for Y after clicking "add" I add this data to the table and I have 2 objects, etc ... but only one marker from state.items is displayed on the map, although I have more coordinates in the table.I know that the componentDidMount () method is only run once and here is the problem.Please Help
state={
items:[{
"X": 13.6155611,
"Y": 51.0331258
},
],
}
addItem = (e) => {
e.preventDefault();
const newItem = {
"Y": parseFloat(this.state.X),
"X": parseFloat(this.state.Y),
};
this.setState(prevState => ({
items: [...prevState.items, newItem]
}));
}
componentDidMount() {
const map = new mapboxgl.Map({
container: this.mapContainer,
center: [this.state.lng, this.state.lat],
zoom: this.state.zoom,
});
for (var i = 0; i < this.state.items.length; i++) {
var obj = this.state.items[i];
let myLatlng = new mapboxgl.LngLat(obj.X, obj.Y);
new mapboxgl.Marker()
.setLngLat(myLatlng)
.addTo(map);
}
}
render() {
return (
<div ref={el => this.mapContainer = el} />
<form onSubmit={this.addItem}>
<input
type="number"
value={this.state.X}
onChange={e => this.setState({
X: e.target.value
})}
/>
<input
value={this.state.Y}
onChange={e => this.setState({
Y: e.target.value
})}
/>
</Form>
)}
|
|
|
|
|
is it possible to use this bootstrap table with data tables plugin? can anyone please help me out... as I want to change the view of datatables views. it looks outdated...
|
|
|
|
|
Try asking the people who wrote it.
|
|
|
|
|
Bootstrap is just css so yes, you can apply it.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hi,
You could definitely use it. Thanks.
Cheers,
Jin
|
|
|
|
|
Hi this works, but i would like to add other CountryCodes to include all french speaking countries.
<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script language="JavaScript">
if(geoplugin_countryCode() != 'US'){
if(geoplugin_countryCode() == 'FR'){
location.href = "indexfr.html";
}else{
location.href = "//index.html";
}
}
</script>
if (Type == 2 && (PageCount == 0 || PageCount == '')) {
as if commented out part worked....
the geoplugin generates the country code
Any help welcome
thanks
Peter
|
|
|
|
|
Member 14807823 wrote: as if commented out part worked. What happens when you uncomment it?
|
|
|
|
|
Hi Richard,
The commented part was to illustrate what I was trying to do, it wont work.
so it wont go to the indexfr.html page
Thanks
Peter
|
|
|
|
|
I think your syntax is not correct, try this:
var cc = geoplugin_countryCode();
if (cc == 'FR'|| cc =='CH' || cc =='LU' || cc =='BE' || cc =='LI'){
location.href = "indexfr.html";
}
|
|
|
|
|
Hi Richard,
Yes it was the syntax,
that was the neat and correct solution
Thanks
Peter
|
|
|
|
|
Yes, and I should have spotted it the first time. I will try harder in future.
|
|
|
|
|
It looks like all you need to do is debug it. I'm not sure what you were wanting us to do.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hi Richard
Mainly I wantad to know if that should work, looking around is seems not to be correct..
I dont know how to debug it.
thanks
Peter
|
|
|
|
|
Member 14807823 wrote: I dont know how to debug it. That is the most important skill to have when writing code.
Basically, press F12 in your browser and your browser's developer tools will open. First, check the console to see if you have errors. Then you can click in the line of code you want to test and create a breakpoint.
Too much to go into here, but yes, you'll want to learn to debug.
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Hi ZuroDev,
Yes I know
thanks
Peter
|
|
|
|
|
for what this script? can use in website streaming?
|
|
|
|
|
I'm just getting started and learning through a book and this code won't run on google, was wondering why and what I needed to do to fix it. Thank you in advance.
<pre>
function zeroPad(number, width) {
let string = String(number);
while (string.length < width){
string = "0" + string;
}
return string;
}
function printFarmInventory(cows, chickens, pigs) {
console.log(`${zeroPad(cows, 3)} Cows`);
console.log(`${zeroPad(chickens, 3)} Chickens`);
console.log(`${zeroPad([pigs], 3)} Pigs`);
}
printFarmInventory(7, 16, 3);
|
|
|
|
|
Hi JaHowler,
Maybe you can try this.
function zeroPads(animal, width){
let strNumber = animal.toString(),
len = strNumber.length;
while(len < width){
strNumber += `0${strNumber}`;
len++;
}
return strNumber;
}
function printFarmInventory(cows, chickens, pigs){
console.log(`${zeroPads(cows,3)} Cows`);
console.log(`${zeroPads(chickens, 3)} Chickens`);
console.log(`${zeroPads(pigs, 3)} Pigs`);
}
printFarmInventory(7,16,3);
Output:
"7070707 Cows"
"16016 Chickens"
"3030303 Pigs"
Hope this helps. Thanks.
Cheers,
Jin
|
|
|
|
|
Thank you, I appreciate your time and help
|
|
|
|
|
That code works fine for me in Firefox and Chrome. Which browser are you using, and what errors are you getting?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a Windows alert, after I click ok I want to chain the asychronous methods as synchronous. Not sure how?
alert('test')
.then(() => {
})
.then(() => {
})
.then(() => {
})
.then(() => {
});
I thought about using promise in JavaScript, but not clue so far.
|
|
|
|
|
alert pauses your code until the user clicks "OK", so there's no need for a promise.
NB: Since you've dropped support for Internet Explorer (which doesn't support arrow functions[^]) you might as well use an async function[^]. That will make your code easier to read.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
how can I use it what is it and how can I start hacking easily
|
|
|
|
|
|
var map = new ol.Map({
renderer: 'canvas',
target: 'map',
layers: [layer],
view: view
});
var vectorLayer = new ol.layer.Vector({
source:new ol.source.Vector({
features: [new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([-0.12755, 51.507222], 'EPSG:4326', 'EPSG:3857')),
})]
})
|
|
|
|