×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    2

    setting map.box zooms all the way out

    Hi,
    I have a problem using nokia.mh5.components.Map.

    I have a map object, it is already attached to my DOM and I'm trying the following call:

    Code:
    map.box = [{latitude: 52.48418475521959, longitude: 13.247291576673867}, {latitude: 51.568805705543554, longitude: 13.737773218142548}];
    This centers the box correctly, but also it zooms out to zoom level 3 (which is not of much use).

    Calling now
    Code:
    map.covers([{latitude: 52.48418475521959, longitude: 13.247291576673867}, {latitude: 51.568805705543554, longitude: 13.737773218142548}])
    returns true - which is obviously correct, but after I call
    Code:
    map.zoom = 5;
    which zooms in a bit but still shows the whole of europe, the same call to map.covers already returns false - even though both of these coordinates are in eastern germany, so the call should obviously return true!


    Can anybody tell me if this is a bug or if I'm just calling the wrong methods to zoom into a box?

  2. #2
    Regular Contributor
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: setting map.box zooms all the way out

    You are calling the right method, but just at the wrong time. If the box is set before the map has completely initialized, the zoom level will be incorrect.

    Consider the following map:

    Code:
    var app =
    	nokia.mh5.app.embed ({
    		domNode: "#app_location",
    		appId: "YOUR_APP_ID",
    		appCode: "YOUR_TOKEN",
    		hideAddressBar: true,
    		configuration: {
    			map: {
    				center: {
    					longitude: 13.3896145,
    					latitude: 52.5166648
    				},
    				zoom: 15,
    				schema: "normal.day"
    				
    			}
    		}
    	});
    This will show the city of Berlin when the app is initialized (or the previous location stored in the cache if the app has run before- which is the default behavior for an embedded app).
    Calling the following:
    Code:
    var map = nokia.mh5.app.controller.getMap();
    var zoomToLondon = function(){
    	map.box = [{latitude: 51.7, longitude: -0.2}, {latitude: 51.3, longitude: -0.6} ];	
    };
    map.listeners.ready = zoomToLondon;
    will force the app to update the location to a bounding box surrounding the city of London - but only once the map has full loaded.

    If however the call was made directly to zoomToLondon();, then the odd zoom behavior would occur.



    The alternative would be to use the lower level framework directly - following code would zoom to London directly every time:
    Code:
        <div id="shapes"></div>
        <script type="text/javascript">
            nokia.mh5.assetsPath = "../../lib/";
            nokia.mh5.appId = "YOUR_APP_ID";
            nokia.mh5.appCode = "YOUR_TOKEN";
    
    	var zoomToLondon = function(){
    			map.box = [{latitude: 51.7, longitude: -0.2}, {latitude: 51.3, longitude: -0.6} ];	
    	}
    	
            var map = new nokia.mh5.components.Map({
                    schema: "normal.day",
                    center: {
                        latitude: 52.53049,
                        longitude: 13.385124
                    },
                    zoom: 15,
                    listeners: {
                    	ready : zoomToLondon
                    }
            });
    
    document.getElementById("shapes").appendChild(map.root);
    </script>

Similar Threads

  1. Load the setting items based on another setting item
    By yanamaddinaveen in forum Symbian User Interface
    Replies: 1
    Last Post: 2011-09-28, 08:27
  2. Web browser zooms on double click
    By ranco in forum [Archived] Flash Lite on Nokia Devices
    Replies: 8
    Last Post: 2010-01-19, 11:15
  3. Two-line setting & Multi-selection list setting items
    By azavor in forum Symbian User Interface
    Replies: 2
    Last Post: 2009-06-04, 19:39
  4. Setting list empty type setting item
    By denial347 in forum Symbian User Interface
    Replies: 1
    Last Post: 2009-04-05, 16:23
  5. Replies: 1
    Last Post: 2002-06-04, 05:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×