Domanda

this is the first time I posted something in stackoverflow. Greetings!!

So, I'm tryin' to start a web app using Nokia Maps, so I went to samples and code (copy and paste) the code I encountered. Nothing is displayed.

I know I need to have an app_id and app_code. I have two pf them.

From developer.here.com, when I select a Create App link, a Solution Selection screen appears. I have two app_id and app_code selecting "Web and Web experiences" and "Web and Geocoder & Batch Geocoder".

I guess that the codes aren't valid. But, what kind of solution I need to choose??

Thanks

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="X-UA-Compatible" content="IE=7; IE=EmulateIE9; IE=10" />

    <script src="http://js.api.here.com/se/2.5.3/jsl.js" type="text/javascript" charset="utf-8">   </script>
    <script type="text/javascript">

        nokia.Settings.set("app_id", "My_app_id");
        nokia.Settings.set("app_code", "My_app_code");

        var map = new nokia.maps.map.Display(
            document.getElementById("mapContainer"), {
                // Zoom level for the map
                zoomLevel: 10,
                // Map center coordinates
                center: [52.51, 13.4]
            }
        );
    </script>
</head>
<body>
    <div id="mapContainer"></div>
</body>
È stato utile?

Soluzione

Try adding a height and width to your map container.

 <div id="mapContainer" style="width:540px; height:334px;"></div>

If your app_id and app_code are invalid you should at least get a grey box.

If you place the <div> before the <script> tag then it will be present in the DOM when the script is running. This should work:

<div id="mapContainer" style="width:540px; height:334px;"></div>
<script type="text/javascript">

    nokia.Settings.set("app_id", "My_app_id");
    nokia.Settings.set("app_code", "My_app_code");

    var map = new nokia.maps.map.Display(
    document.getElementById("mapContainer"), {
        zoomLevel: 10,
        center: [52.51, 13.4]
    });
</script>

Also open firebug and see if any map tiles are being downloaded or if you have any JavaScript errors.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top