2017-11-27 12 views
1

私はPhonegapでAndroid向けGoogleマップアプリを作ってメッセージのようなマーカーを追加できます。メッセージは今のところローカルに保存されています。だから、私は今どのようにアプリが見えるの写真を含めた。 Here is the App私はGoogleマップベースのアプリケーションを作成する際にアドバイスが必要です

したがって、osoiteはアドレスを意味し、Viestiはメッセージを意味し、lisäämerkintäはメモを追加することを意味します。だからここ

は、インデックスのHTMLコードです:

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8"> 
     <meta name="format-detection" content="telephone=no" /> 
     <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
     <link rel="stylesheet" type="text/css" href="css/index.css" /> 

     <link rel="stylesheet" 
     href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> 

     <script src="https://code.jquery.com/jquery-2.1.4.js" 
     integrity="sha256-siFczlgw4jULnUICcdm9gjQPZkw/YPDqhQ9+nAOScE4=" 
     crossorigin="anonymous"></script> 

     <script 
     src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> 

     <title>Kartta</title> 
    </head> 
    <body> 

    <div id="pageOne" data-role="page"> 
    <div data-role="header"> 
     <h1>Kartta</h1> 
    </div> 
    <div role="main" class="ui-content ui-body-a"> 
     <div id="geolocation" style="width: 285px; height: 370px;"> 
     </div> 

     <div role="main" class="ui-content ui-body-a"> 
      <p id="pageOne"> 
      </p> 

     </div> <!-- /content --> 

    </div> 
    <div data-role="footer"> 
     <label for="textinput-hide" class="ui-hidden-accessible">Osoite</label> 
     <input type="text" class="Osoite" name="textinput-hide" id="textinput-hide" placeholder="Osoite" 
     <br> 
     <label for="textinput-hide" class="ui-hidden-accessible">Viesti</label> 
     <input type="text" class="Viesti" name="textinput-hide" id="textinput-hide" placeholder="Viesti"> 
     <br> 
     <button class="ui-btn">Lisää merkintä</button> 
    </div> <!-- /footer --> 
    </div> 

      <script type="text/javascript" src="phonegap.js"></script> 
      <script type="text/javascript" src="js/index.js"></script> 
      <script src="http://maps.googleapis.com/maps/api/js?key=(My own key)"> 
      </script> 
      <script type="text/javascript" src="cordova.js"></script> 

      <script type="text/javascript"> 
      $(document).on("pageOne", "#marker", function() { 

      $.ajax({ 
        url: "https://maps.googleapis.com/maps/api/geocode/json?address=1600+Ratapihantie,+Pasila,+FI&key=(My own key)", 
        datatype: "json", 
        timeout: 5000 
      }) 
      .done(function(data) { 
       var marker= results[0].geometry.location.lat 
       var marker2= results[0].geometry.location.lng 

      }) 
        }); 

       app.initialize(); 
      </script> 
    </body> 
</html> 

そして、ここでは、Javascriptのためのコードです:

var app = { 
    // Application Constructor 
    initialize: function() { 
     this.bindEvents(); 
    }, 
    // Bind Event Listeners 
    // Bind any events that are required on startup. Common events are: 
    // 'load', 'deviceready', 'offline', and 'online', 

    bindEvents: function() { 
     document.addEventListener('deviceready', this.onDeviceReady, false); 
    }, 
    // deviceready Event Handler 
    // The scope of 'this' is event. In order to call the 'receivedEvent' 
    // function, we must explicity call 'app.receivedEvent(...);' 
    onDeviceReady: function() { 
     app.receivedEvent('deviceready'); 
     app.receivedEvent('deviceready');  
     // Get our current location 
     navigator.geolocation.getCurrentPosition(app.onSuccess, app.onerror); 
    }, 

    // Current location was found 
    // Show the map 
    onSuccess: function(position) { 
     var longitude = position.coords.longitude; 
     var latitude = position.coords.latitude; 
     var latLong = new google.maps.LatLng(latitude, longitude); 

     var mapOptions = { 
      center: latLong, 
      zoom: 16, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     }; 

     var map=new google.maps.Map(document.getElementById("geolocation"), mapOptions); 
    }, 

    // Current location could not be determined 
    // Show error 
    onerror: function(error) { 
     alert('code: ' +error.code + '/n' + 'message: ' + error.message + '\n'); 
    }, 

    // Update DOM on a Received Event 
    receivedEvent: function(id) { 

    } 


}; 

私はちょうどメッセージでマーカーを追加することを支援する必要があります。

答えて

関連する問題