Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.lang.javascript > #8249
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Alessandro Pellizzari <shuriken@amiran.it> |
| Newsgroups | it.comp.lang.javascript |
| Subject | Re: trasmissione dati |
| Date | Sat, 28 Apr 2018 16:34:20 +0100 |
| Lines | 38 |
| Message-ID | <fkjijtFirmkU1@mid.individual.net> (permalink) |
| References | <20180428105816.07568b7e@nntp.aioe.org> <fkj276Ff84fU1@mid.individual.net> <20180428162258.48aa8b4d@nntp.aioe.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net 2I4Hx99T9zD+1aKOFGWbCg9gxXsrLdOIQt/h0hh7sqnZqPE4Y= |
| Cancel-Lock | sha1:xV8lVNSHC5uDy45m7HUD/GEleRo= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
| In-Reply-To | <20180428162258.48aa8b4d@nntp.aioe.org> |
| Content-Language | en-GB |
| Xref | csiph.com it.comp.lang.javascript:8249 |
Show key headers only | View raw
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