我需要建议制作基于谷歌地图的应用程序

时间:2017-11-27 19:00:29

标签: javascript android html cordova phonegap

所以我正在尝试使用Phonegap为Android创建一个谷歌地图应用程序,我可以在其中添加类似邮件的标记。此消息暂时存储在本地。所以我在图片中添加了应用程序的外观。 Here is the App

所以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) {

    }


};

我只是需要帮助添加标记和消息。

0 个答案:

没有答案