Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it L'avatar di Mon91
    Registrato dal
    Jul 2013
    Messaggi
    52

    problema con i google markers

    Ragazzi ho a che fare con le API di Google e ho un problema! (Ho postato la stessa problematica come continuazione della discussione che è stata spostata in javascript in quanto non presentava codice java; qui ho riportato anche esso)
    CMQ
    posto la pagina jsp:
    codice:
         <!DOCTYPE html>
    <html>
      <head>
        <jsp:useBean class="beans.Bean" id="gpb"></jsp:useBean>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <style type="text/css">
          #map-canvas { height: 100%; 
                        width: 100%;
                        border: 0%;
                        padding: 0%;
                      }
                    
        </style>
        <script type="text/javascript"
          src="https://maps.googleapis.com/maps/api/js?sensor=false">
        </script>
        <script type="text/javascript">
          
          
          function addMarker(posizione, titolo,contenuto){
            var marker = new google.maps.Marker({
             position: posizione,
             map: map,
             title:titolo  }); 
             
             var infowindow = new google.maps.InfoWindow({content: contenuto});
             google.maps.event.addListener(marker, 'click', function() {infowindow.open(map, marker);});         
             return marker;
          }
          
          function geocode(indirizzo,desc,content){
            geocoder.geocode( { 'address': indirizzo}, function(results, status) {
                                                            if (status == google.maps.GeocoderStatus.OK) {
                                                            addMarker(results[0].geometry.location,desc,content);
                                                                                    }
                                                                                 }
            );
          }
    
          var map;
          var geocoder = new google.maps.Geocoder();
          function initialize() {
            var mapOptions = {
              center: new google.maps.LatLng(44.6885,10.6649),
              zoom: 9,
              mapTypeId: google.maps.MapTypeId.ROADMAP
              
              /*
              ROADMAP displays the normal, default 2D tiles of Google Maps.
              SATELLITE displays photographic tiles.
              HYBRID displays a mix of photographic tiles and a tile layer for prominent features (roads, city names).
              TERRAIN displays physical relief tiles for displaying elevation and water features (mountains, rivers, etc.).
              */
             
            };
            map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
          }
          
          
          
          function addP() {
            
            
            <%=gpb.getElements()%>
          
          }
          
          google.maps.event.addDomListener(window, 'load', initialize);
        </script>
      </head>
      <body>
        <h1 onclick="addP()"><strong><u>Cliccando qui</u> potrete visualizzare le sedi convenzionate con noi!</strong></h1>
        <div id="map-canvas"/>
      </body>
    </html> 
     come si può vedere questa pagina è legata ad un bean scritto in java, ma per comodità non sto a riportare tutto il programma, che funziona correttamente,ma posto solamente una parte ciò che stampa(una parte in realtà x l'eccessiva lunghezza):
          codice:
         geocode("Modena (Mo) Via Emilia Est","Aguzzi Franco Alimentari","<h74>Tel  059 243293</h74>");
    geocode("Castelfranco Emilia (Mo) 6, Via Loda","Coop Estense (Soc.Coop.R.L.)","<h75>Tel  059 926141</h75>");
    geocode("Carpi (Mo) 31, Via Industria","Brico Business Cooperation Srl","<h76>Tel  059 691531</h76>");
    geocode("Modena (Mo) 1381, Via Emilia Est","Brico Business Cooperation Srl","<h77>Tel  059 285407</h77>");
    geocode("Vignola (Mo) 20, Via Della Resistenza","C.G. Snc Di Cavedoni Cinzia e Notari Giuseppe","<h78>Tel  059 767071</h78>");
    geocode("Modena (Mo) 500, Strada Delle Morane","Centro Commerciale La Rotonda G.D. Srl","<h79>Tel  059 448111</h79>");
    geocode("Bastiglia (Mo) 24, Via Tintori","Centro Commerciale Mazzone S.R.L.","<h80>Tel  059 816042</h80>");
    ORA VENIAMO AL PROBLEMA: SE FACCIO LA CHIAMATA A GEOCODE "MANUALMENTE" cioè in maniera statica, quando apro la pagina viene visualizzata la mappa con i tre o quattro (o anche tutti) i markers di prova; INVECE SE LO FACCIO IN MANIERA DINAMICA CON <%=gpb.getElements()%> NON SOLO NON VISUALIZZA I MARKER, MA NEANCHE LA MAPPA, COME SE IL CODICE INTERFERISSE IN UN QUALCHE MODO... la console web dice:
    codice:
         [16:21:17.556] ReferenceError: addP is not defined @ http://localhost:8080/nuovo/new.jsp?...a=restaurant:1
    NON SO DAVVERO COME FARE, NON HA SENSO! PER DI PIU' LA CONSOLE WEB MOSTRA CORRETTAMENTE TUTTE LE CHIAMATE A GEOCODE QUINDI IL PROBLEMA NON E' LI.
    SPERO POSSIATE AIUTARMI!
    Ultima modifica di LeleFT; 22-10-2013 a 09:29

  2. #2
    Utente di HTML.it L'avatar di Mon91
    Registrato dal
    Jul 2013
    Messaggi
    52
    RAGAZZI FINALMENTE MOSTRA I MARKERS, MA, PERCHE' Cè SEMPRE UN MA NON LI MOSTRA TUTTI!
    codice:
    function addMarker(posizione, titolo,contenuto){
            var marker = new google.maps.Marker({
             position: posizione,
             map: map,
             title:titolo  }); 
             
             var infowindow = new google.maps.InfoWindow({content: contenuto});
             google.maps.event.addListener(marker, 'click', function() {infowindow.open(map, marker);});         
             return marker;
          }
          
          function geocode(indirizzo,desc,content){
            geocoder.geocode( { 'address': indirizzo}, function(results, status) {
                                                            if (status == google.maps.GeocoderStatus.OK) {
                                                            addMarker(results[0].geometry.location,desc,content);
                                                                                    }
                                                                                 }
            );
          }
    
          var map;
          var geocoder = new google.maps.Geocoder();
          function initialize() {
            var mapOptions = {
              center: new google.maps.LatLng(44.6885,10.6649),
              zoom: 9,
              mapTypeId: google.maps.MapTypeId.ROADMAP
              
              /*
              ROADMAP displays the normal, default 2D tiles of Google Maps.
              SATELLITE displays photographic tiles.
              HYBRID displays a mix of photographic tiles and a tile layer for prominent features (roads, city names).
              TERRAIN displays physical relief tiles for displaying elevation and water features (mountains, rivers, etc.).
              */
             
            };
            map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
          }
          
    
          google.maps.event.addDomListener(window, 'load', initialize);
    codice:
    <html>
      <head>
        <jsp:useBean class="beans.Bean" id="gpb"></jsp:useBean>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <style type="text/css">
          #map-canvas { height: 100%; 
                        width: 100%;
                        border: 0%;
                        padding: 0%;
                      }
                    
        </style>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript" src="main.js"></script>
        <script type="text/javascript">
        function addP(){
        <%=gpb.getElements()%>
        }
        </script>
      </head>
      <body>
        <h1 onclick="addP()"><strong><u>Cliccando qui</u> potrete visualizzare le sedi convenzionate con noi!</strong></h1>
        <div id="map-canvas"></div>
      </body>
    </html>
    HO CREATO UNA APPOSITA PAGINA JS, COME CONSIGLIATO! NON STO A RIPOSTARE IL CODICE JAVA CHE NON CREA PROBLEMI!

    COME POSSO RISOLVERE IL FATTO CHE MOSTRI SOLTANTO DIECI SU CIRCA NOVANTA MARKERS?

    GRAZIE DAVVERO A TUTTI PER L'ATTENZIONE CHE MI AVETE DATO FIN DAI PRIMI GIORNI... GRAZIE RAGAZZI

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Continua a restare un problema di javascript, ovvero di JSP / Bean fintanto che il prodotto HTML / Javascript degli scriplet / Bean non sia conforme a quanto atteso dai metodi delle API di google maps. Potresti linkare un output completo e postare il codice server side, giusto per renderci conto di quello che succede?
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  4. #4
    Utente di HTML.it L'avatar di Mon91
    Registrato dal
    Jul 2013
    Messaggi
    52
    codice JAVA con cui creo il database riempendolo da un file di testo così composto:

    Billa Ag; Castel San Giovanni, Via Fellegara 1; Tel: 0523 882475
    C.Market Srl; Gragnano Trebbiense, Via Trieste 4; Tel: 0523 788373
    Capuano Anna; Podenzano, Via C. Colombo 72; Tel: 0523 551097
    Centro Commerciale Gotico; Piacenza, Via Emilia Parmense 10; Tel: 0523 606851
    Ciesseci Spa; Castel San Giovanni, Via Emilia Piacentina 56; Tel: 0523 849302
    Colombi Nadir Supermercati; Piacenza, Via Torta Francesco 1; Tel: 0523 339195
    Conad Supermercati; San Giorgio Piacentino, Via Firenze 1; Tel: 0523 370154
    Esselunga Spa; Parma, V. Pertini 14/A; Tel: 0521 463376
    La Cittadella; Parma, V. Franklin 31; Tel: 0521 606241
    Panorama Spa; Parma, V. Pellico 20/A; Tel: 041 2916600
    codice:
    package beans;
    
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.Statement;
    import java.util.ArrayList;
    public class Main {
    
    
        public static void main (String [] args) throws Exception {
    
            Class.forName("org.sqlite.JDBC");
            Connection c = DriverManager.getConnection("jdbc:sqlite:db1.db");
            Statement s = c.createStatement();
    
                    
            
            s.executeUpdate("drop table places");
            s.executeUpdate("create table places (" +
                    "codice INTEGER PRIMARY KEY," + 
                    "nome1 VARCHAR(50), " +
                    "localita1 VARCHAR(50), " +
                    "telefono1 VARCHAR(50))");
            
            BufferedReader br = new BufferedReader( new FileReader("Docs/DB.txt"));
            String line;
            String querySQL = "";
            int codice = 0;
            while((line=br.readLine())!=null){
                String t=line.replaceAll(":", " ");
                t=t.replaceAll("'", " ");
                String [] w=t.split(";");
                String nome=w[0].trim();
                String localita=w[1].trim();
                String telefono=w[2].trim();
            
                querySQL = "insert into places(codice,nome1,localita1,telefono1) values('" + codice +"','" + nome + "', '" + localita + "', '" + telefono +"')"; 
                s.executeUpdate(querySQL);
                codice++;
            }br.close();
    
    
    
        }
    }




    codice java che interroga il database e stampa le chiamate a geocode():
    codice:
    package beans;
    
    import java.sql.*;
    
    public class Bean {
    
        
        public String getElements() throws Exception{
    
            Class.forName("org.sqlite.JDBC");
            Connection c = DriverManager.getConnection("jdbc:sqlite:/C:/Users/eleonora/workspace/Tesina/db1.db");
            
            Statement s = c.createStatement();                             
    
            String querySQL = "";
            querySQL= "SELECT * FROM places";
            ResultSet rs=s.executeQuery(querySQL);
            String odio="";
            Integer z=0;
            
            while(rs.next()){
                z=z+1;
                String localita=rs.getString("localita1");
                String nome=rs.getString("nome1");
                String telefono=rs.getString("telefono1");
                odio=odio+"geocode("+ "\"" +localita+", Italia\""+ "," +"\"" +nome+"\"" + "," +"\"" +"<h"+z+">"+telefono+"</h"+z+">\"" +");"+ "\r\n";
                
            }
            
            rs.close();
            s.close();
            c.close();
            
            return odio;
        }
        
        //per controllare se funziona 
        
        public static void main(String args[]) throws Exception{
            Bean b=new Bean();
            
            System.out.println(b.getElements());
    
        }
    
    }
    STAMPA SOLO UNA DECINA DI MARKERS SU CIRCA TRENTA? LI HO RIDOTTI DAI NOVANTA CHE ERANO EPPURE ONLINE NON HO TROVATO CHE CI SIANO LIMITI AI MARKERS CHE PUOI AGGIUNGERE AD UNA MAPPA GOOGLE. ANCORA NON ME LO SPIEGO!

  5. #5
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Adesso posta l'HTML completo (o se puoi, linkalo da qualche parte)
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  6. #6
    Utente di HTML.it L'avatar di Mon91
    Registrato dal
    Jul 2013
    Messaggi
    52
    Posto jsp e js, cioè le pagine che si occupano di creare i markers:

    codice:
    <html>
      <head>
        <jsp:useBean class="beans.Bean" id="gpb"></jsp:useBean>
        <link href="http://fonts.googleapis.com/css?family=Arvo" rel="stylesheet" type="text/css" />
            <link href="default.css" rel="stylesheet" type="text/css" />
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <style type="text/css">
          #map-canvas { height: 100%; 
                        width: 100%;
                        border: 0%;
                        padding: 0%;
                      }
                    
        </style>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
        <script type="text/javascript" src="main.js"></script>
        <script type="text/javascript">
        function addP(){
        <%=gpb.getElements()%>
        }
        </script>
      </head>
      <body>
            <h1 onclick="addP()"><strong><u>Cliccando qui potrete visualizzare le sedi convenzionate con noi!</u></strong></h1>
            <div id="map-canvas"></div>
    </body>
    </html>
    codice:
    function addMarker(posizione, titolo,contenuto){
            var marker = new google.maps.Marker({
             position: posizione,
             map: map,
             title:titolo  }); 
             
             var infowindow = new google.maps.InfoWindow({content: contenuto});
             google.maps.event.addListener(marker, 'click', function() {infowindow.open(map, marker);});         
             return marker;
          }
          
          function geocode(indirizzo,desc,content){
            geocoder.geocode( { 'address': indirizzo}, function(results, status) {
                                                            if (status == google.maps.GeocoderStatus.OK) {
                                                            addMarker(results[0].geometry.location,desc,content);
                                                                                    }
                                                                                 }
            );
          }
    
          var map;
          var geocoder = new google.maps.Geocoder();
          function initialize() {
            var mapOptions = {
              center: new google.maps.LatLng(44.900,9.983),
              zoom: 9,
              mapTypeId: google.maps.MapTypeId.ROADMAP
              
              /*
              ROADMAP displays the normal, default 2D tiles of Google Maps.
              SATELLITE displays photographic tiles.
              HYBRID displays a mix of photographic tiles and a tile layer for prominent features (roads, city names).
              TERRAIN displays physical relief tiles for displaying elevation and water features (mountains, rivers, etc.).
              */
             
            };
            map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
          }
          
    
          google.maps.event.addDomListener(window, 'load', initialize);
    La tesina web (il sito) mi è valso un 28 (CHE FA MEDIA CON L'ALTRA META' D'ESAME CIOE' JAVA VERO E PROPRIO CHE AVRO' L'OTTO NOVEMBRE).
    Sarebbe stato un trenta se avessi implementato un qualcosa (che teneva conto di eventuali limitazioni, anche se sul web non vi è traccia di limitazioni) che avesse portato alla soluzione del problema markers cioè un programma che adottasse una qualche soluzione tenendo conto di eventuali limitazioni date dalle funzioni google.
    [google developer dice che non ci sono limiti ai marker che puoi mettere su di una mappa, ma ho trovato un articolo che accenna ad un limite di caratteri... circa 2000 mi pare, purtroppo non ricordo precisamente legati a cosa.. e non trovo più quel xxxxx di articolo]
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`> grazie mille per l'aiuto datomi, davvero.
    Grazie a tutti

  7. #7
    Utente di HTML.it L'avatar di Mon91
    Registrato dal
    Jul 2013
    Messaggi
    52
    Scusate se aggiungo questo commento tardi, ma purtroppo non posso più modificare!
    Il voto 28 è dell'esame Tecnologie Internet e Web e prevede per metà di creare un sito e per metà di lavorare su di un programma in Java e fare certe modifiche.
    Il sito che ho creato presenta diverse cose che ha spiegato al corso e diciamo che il voto è stato alzato rispetto ad un 23-25 dal fatto che ho personalmente integrato facebook (like, login, commenti) studiandolo per conto mio, per quanto non sia difficile.
    Non voglio giustificare proprio niente, ma scrivo perchè ci sono sempre dei personaggi che sputano su certi voti o su certi prof, ma ho sudato, credetemi!
    Ciao!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.