1

私は nokia here マップを Android webview に埋め込もうとしていますが、本当にうまく動作します。問題はマーカークリックリスナーにあります。ブラウザーでhtmlファイルを開くと、リスナーが起動しますが、Android Webビューでは起動しません。HTMLボタンを使用するとonclickが機能するため、JavaScriptイベントがWebビューで正しく構成されていると確信しています。

これは hml ページです

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9; IE=10" />
<base
    href="http://developer.here.com/apiexplorer/examples/api-for-js/markers/marker.html" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>Nokia Maps API for JavaScript Example: Adding a marker</title>
<meta name="description"
    content="Putting a standard marker onto the map" />
<meta name="keywords" content="standardmarker, map objects, markers" />
<!-- For scaling content for mobile devices, setting the viewport to the width of the device-->
<meta name=viewport
    content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!-- Styling for example container (NoteContainer & Logger)  -->
<link rel="stylesheet" type="text/css"
    href="http://developer.here.com/apiexplorer/examples/templates/js/exampleHelpers.css" />
<!-- By default we add ?with=all to load every package available, it's better to change this parameter to your use case. Options ?with=maps|positioning|places|placesdata|directions|datarendering|all -->
<script type="text/javascript" charset="UTF-8"
    src="http://js.cit.api.here.com/se/2.5.3/jsl.js?with=maps"></script>
<!-- JavaScript for example container (NoteContainer & Logger)  -->
<script type="text/javascript" charset="UTF-8"
    src="http://developer.here.com/apiexplorer/examples/templates/js/exampleHelpers.js"></script>
<style type="text/css">


body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    position: absolute;
}

#mapContainer {
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    position: absolute;
}
</style>
</head>
<body>
    <div id="mapContainer"></div>
    <div id="uiContainer"></div>


    <script type="text/javascript" id="exampleJsSource">
        /*  Setup authentication app_id and app_code 
         *  WARNING: this is a demo-only key
         *  please register for an Evaluation, Base or Commercial key for use in your app.
         *  Just visit http://developer.here.com/get-started for more details. Thank you!
         */


        nokia.Settings.set("app_id", "DemoAppId01082013GAL");
        nokia.Settings.set("app_code", "AJKnXv84fjrb0KIHawS0Tg");
        // Use staging environment (remove the line for production environment)
        nokia.Settings.set("serviceMode", "cit");

        // Get the DOM node to which we will append the map
        var mapContainer = document.getElementById("mapContainer");
        // Create a map inside the map container DOM node
        var map = new nokia.maps.map.Display(mapContainer, {
            // Initial center and zoom level of the map
            center : [ 52.51, 13.4 ],
            zoomLevel : 10,
            // We add the behavior component to allow panning / zooming of the map
            components : [ new nokia.maps.map.component.Behavior() ]
        });

        var fernsehturmMarker = new nokia.maps.map.StandardMarker(
                new nokia.maps.geo.Coordinate(52.520816, 13.409417), {
                    title : 'This has a click event',
                    brush : {
                        color : '#00AA00'
                    }
                });
        fernsehturmMarker.addListener('click', function(evt) {
            //$('.loc').html(times[i]); 
            alert('');
        });
        /* Create a marker on a specified geo coordinate 
         * (in this example we use the map's center as our coordinate)
         */
        //var standardMarker = new nokia.maps.map.StandardMarker(map.center);
        // Next we need to add it to the map's object collection so it will be rendered onto the map.
        map.objects.add(fernsehturmMarker);


    </script>
</body>
</html>

これはonCreateメソッドの私のJavaコードです

nokiaMap = (NoZoomControllWebView) getActivity().findViewById(R.tab_map_nokia.webView);
nokiaMap.getSettings().setJavaScriptEnabled(true);
nokiaMap.getSettings().setDomStorageEnabled(true);
nokiaMap.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
nokiaMap.getSettings().setSupportMultipleWindows(true);
nokiaMap.setWebChromeClient(new WebChromeClient() );
nokiaMap.loadUrl("file:///android_asset/marker.html");

誰かが同じ問題を抱えていましたか?

4

1 に答える 1