×

Discussion Board

Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Mobile mh5 markers and infobubbles

    The error

    Code:
    "Uncaught TypeError: Cannot read property 'cartopoi' of undefined"
    comes from infoBubble:, it should be infobubble: (documentation bug?)
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  2. #17
    Registered User
    Join Date
    Jul 2012
    Posts
    6

    Re: Mobile mh5 markers and infobubbles

    Thanks, that helps! Listeners are now called.

    But now in my more complicated code (not the one I pasted) after clicking a bit on map I'm getting "INDEX_SIZE_ERR: DOM Exception 1: Index or size was negative, or greater than the allowed value. -- From line 295 of http://api.maps.nokia.com/mobile/0.1.9/lib/mh5.js" in Android WebView , and in Chrome "Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 ".

  3. #18
    Nokia Developer Moderator
    Join Date
    Sep 2004
    Location
    Tampere, Finland
    Posts
    11,359

    Re: Mobile mh5 markers and infobubbles

    I remember seeing that kind of errors as well, but I don't remember how I got past them. I'm only scratching the surface when it comes to web apps so I hope Leo can give you some better advice.
    -- Lucian

    If you are not yet a DVLUP member it is time to correct that mistake :) Click here to join: http://www.dvlup.com/lucian/Invite

  4. #19
    Nokia Developer Expert
    Join Date
    Mar 2012
    Posts
    65

    Re: Mobile mh5 markers and infobubbles

    Thanks Lucian for your answer. It's really infobubble in the version 0.1.9 and it's a bug. We'll change it to infoBubble.
    @ m00zg:
    Could you describe more precisely the status of the map:
    - does it have pois already;
    - what are the steps to reproduce this error.

    At the first sight it looks like the size (width and height) of the poi are calculated wrong (line 295: D.drawImage(q.image,n-(h=q.width/ha)/2,p-(j=q.height/ha)/2,h,j)).
    What are the poi images you use? Are they the default ones?

    Leo

  5. #20
    Registered User
    Join Date
    Jul 2012
    Posts
    6

    Re: Mobile mh5 markers and infobubbles

    You can simply reproduce the error using the full code I've pasted yesterday. Just change infoBubble into infobubble. And try longpress on map. The default bubble should be shown, but all I get is only the error (set of the same errors):
    Uncaught Error: INVALID_STATE_ERR: DOM Exception 11
    There aren't any POI on map.

    But it's the same if I add my custom POI (with custom icon) and click on it. Poiclick function is empty. No infoBubble is shown, and I get the same error.

  6. #21
    Nokia Developer Expert
    Join Date
    Mar 2012
    Posts
    65

    Re: Mobile mh5 markers and infobubbles

    It's a bug in our code. Currently, if you define listeners on the infobubble you have to define the content property as well. We'll take care of this bug in the next release, but for now please use this:
    Code:
    infobubble: {
                        content: ["title"],//depending on the layout of your infobubble
                        listeners: {
                            click: function(e){},
                            leftclick: function(e){},
                            rightclick: function(e){}
                        }
                    }

  7. #22
    Registered User
    Join Date
    Jul 2012
    Posts
    6

    Re: Mobile mh5 markers and infobubbles

    Thank you. Now it works correctly

  8. #23
    Registered User
    Join Date
    Apr 2010
    Location
    Rosario, Argentina
    Posts
    38

    Re: Mobile mh5 markers and infobubbles

    Can I use HTML code in the infobubble like this:
    http://www.developer.nokia.com/Commu...ble_on_the_map

    I know that documentation is for the web api and not the mobile one, is there any way to use it in mobile? Maybe change the layout of the infobubble?

  9. #24
    Nokia Developer Expert
    Join Date
    Mar 2012
    Posts
    65

    Re: Mobile mh5 markers and infobubbles

    Hi,

    Unfortunately, right now it's not provided by the framework. Of cause I'll take care that this feature comes in our backlog.

    Though there is a non-straightforward way to do it, but that means you would need to do the entire work by yourself:
    - create a HTMLElement with the content you would like to show
    - place it on the map. For this you could use the helper function which is not officially public yet: map._map.geoToPoint, which expects an object with latitude, longitude properties and returns proper x,y coordinates of the entire world on the current zoom level (NOT map canvas). That's why they are so huge. To convert them to the canvas coordinates you can use the canvas center which is also the map center at the same time.
    centerCoordWorld = map._map.geoToPoint(map.center);
    centerCoordCanvas = {x: map.size.width / 2, y: map.size.height / 2);
    Having this information it's just a simple math to get canvas coordinates for your specific latitude, longitude.

    - register for touchstart, touchmove, toucheend events to track map movements and move your custom infobubble together with the map.

    Please let us know if you saw any noticeable performance issues.

    Thx,
    Leo

  10. #25
    Registered User
    Join Date
    Apr 2010
    Location
    Rosario, Argentina
    Posts
    38

    Re: Mobile mh5 markers and infobubbles

    Thanks Leo for your help.
    Adding html content to the infobubble looks complicated so I decided to use the conventional ones.
    Just a quick question, can I change the font size of the text displayed in the bubble?
    Thx
    Pam

  11. #26
    Nokia Developer Expert
    Join Date
    Mar 2012
    Posts
    65

    Re: Mobile mh5 markers and infobubbles

    Hi Pam,

    unfortunately, also this is not possible in the current version. What you can do is to draw your infobubble on the canvas and pass the canvas as "image" property of the infobubble parameters to the showInfobubble.

    Using your example below:
    Code:
    
    var myCanvas = document.createElement("canvas");
    myCanvas .height = 120; 
    myCanvas .width = 90;
    var ctx = myCanvas .getContext("2d");
    ctx.fillStyle = "rgb(200,0,0)";
    ctx.fillRect(10, 10, 55, 50);
    ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
    ctx.fillRect(30, 30, 55, 50);  
    
    ......
    listeners:{
    	"poiclick": function(e) {
    
    		var params = {
    			content: ["title","description","more"],
    			image: myCanvas,
    			listeners:{
    				click: function(e){}
    			},
    			maxWidth:340
    		}
    		if(e.data[0].data.state=="FLUENT"){
    			params.left = "img/verde.png";	
    		}
    		if(e.data[0].data.state=="CONGESTED"){
    			params.left = "img/amarillo.png";	
    		}
    		if(e.data[0].data.state=="DELAYED"){
    			params.left = "img/rojo.png";	
    		}
    		if(e.data[0].data.interrupcion=="TOTAL"){
    			params.right = "img/corte_total.png";	
    		}
    		if(e.data[0].data.interrupcion=="PARTIAL"){
    			params.right = "img/corte_parcial.png";	
    		}
    		this.showInfoBubble(e.data[0],params,function(b){console.log(b)});
    		e.preventDefault();
    	}
    }

    As you might have noticed in this case you can specify the click handler only. That means if you have several active parts of the infobubble (e.g. right, middle, left) you will need to calculate the right part based on the coordinates given by the event parameter of the click function.

    Leo

Similar Threads

  1. Map markers not always shown when max zoomed out
    By amnesia7 in forum [Archived] Maps API for Javascript
    Replies: 8
    Last Post: 2012-11-26, 21:06
  2. Google Map URL J2ME markers
    By v2sms in forum Mobile Java General
    Replies: 1
    Last Post: 2010-02-15, 13:04
  3. Multiple markers at this line with RThread
    By gigglie in forum Symbian
    Replies: 1
    Last Post: 2008-06-19, 08:57

Posting Permissions

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