Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.lang.javascript > #8249
| From | Alessandro Pellizzari <shuriken@amiran.it> |
|---|---|
| Newsgroups | it.comp.lang.javascript |
| Subject | Re: trasmissione dati |
| Date | 2018-04-28 16:34 +0100 |
| Message-ID | <fkjijtFirmkU1@mid.individual.net> (permalink) |
| References | <20180428105816.07568b7e@nntp.aioe.org> <fkj276Ff84fU1@mid.individual.net> <20180428162258.48aa8b4d@nntp.aioe.org> |
On 28/04/18 16:13, Enrico Maria Chellini wrote:
> ma nel codice della mappa che ho postato prima invece nel sorgente
> rimane +nome e +myPosition
> +nome +myPosition non me li trasforma nei valori inviati, al contrario
> della funzione "saluta".
>
> in PHP invece metto
> "" var map = L.map('map').setView([<?php echo $myPosition; ?>],
> 12);
Questo perché PHP genera una stringa che poi diventa "codice javascript".
Se sei in Javascript, quella funzione (setView) accetta un parametro che
è un array di floating-point.
Quell che fai tu qui:
var map = L.map('map').setView([+myPosition], 12);
L.marker([+myPosition]).addTo(map)
.bindPopup(+nome).openPopup();
È dirgli: "prendi myPosition e nome, trasformali in numeri e sommaci 0"
Per nome è semplice: togli il +
Per myPosition è più complicato. O passi le due coordinate
separatamente, oppure devi parsare la stringa a mano.
La prima è più semplice:
function showMap( nome, x, y) {
...
var map = L.map('map').setView([x, y], 12);
...
L.marker([x, y]).addTo(map).bindPopup(nome).openPopup();
}
Back to it.comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar
trasmissione dati Enrico Maria Chellini <bitit@bitit.it> - 2018-04-28 10:58 +0200
Re: trasmissione dati Alessandro Pellizzari <shuriken@amiran.it> - 2018-04-28 11:54 +0100
Re: trasmissione dati Enrico Maria Chellini <bitit@bitit.it> - 2018-04-28 17:13 +0200
Re: trasmissione dati Alessandro Pellizzari <shuriken@amiran.it> - 2018-04-28 16:34 +0100
Re: trasmissione dati Enrico Maria Chellini <bitit@bitit.it> - 2018-04-30 12:34 +0200
Re: trasmissione dati Enrico Maria Chellini <bitit@bitit.it> - 2018-04-30 12:38 +0200
Re: trasmissione dati Enrico Maria Chellini <bitit@bitit.it> - 2018-04-30 12:39 +0200
Re: trasmissione dati Enrico Maria Chellini <bitit@bitit.it> - 2018-05-06 18:15 +0200
csiph-web