Skip to content
Browse files

Merge pull request #24 from nbmont/master

Fix a bug in icon-only POIs introduced with pivot points.
  • Loading branch information...
2 parents 1167b72 + 0e0ca63 commit f776360a92399526862d53f888277851eefd2acf @martinchristen martinchristen committed Aug 17, 2012
Showing with 15 additions and 3 deletions.
  1. +2 −3 source/core/poi.js
  2. +13 −0 source/tutorials/04_POI/POI_08_PivotPoint.html
View
5 source/core/poi.js
@@ -177,7 +177,7 @@ Poi.prototype.SetContent = function(text,textStyle,timgurl,iconStyle)
*/
Poi.prototype.SetPosition = function(x,y,z,zs)
{
- //calc poi width
+ //calc this.poiWidth and this.poiHeight
if(this.iconMesh && this.textMesh)
{
this.poiWidth = this.iconMesh.meshWidth + this.textMesh.meshWidth;
@@ -194,8 +194,7 @@ Poi.prototype.SetPosition = function(x,y,z,zs)
this.poiHeight = this.textMesh.meshHeight;
}
- // will evaluate to 0 if there's no icon
- var iconWidth = this.poiWidth - this.textMesh.meshWidth;
+ var iconWidth = this.iconMesh ? this.iconMesh.meshWidth : 0;
var pivotOffsetX = this.centerOnIcon ? -this.pivotX*iconWidth/2 : -this.pivotX*this.poiWidth/2;
if(this.iconMesh)
View
13 source/tutorials/04_POI/POI_08_PivotPoint.html
@@ -172,6 +172,19 @@
// (8.4) then create and add it to the scene
ogCreatePOI(poilayer, PoiDefinitionWithIcon);
+ // (8.5) let's create a poi with icon-only. (text is optional)
+ var PoiDefinitionWithIcon =
+ {
+ icon : "http://www.openwebglobe.org/data/media/airport.png",
+ position : [7.52, 46.71, 2000],
+ size : 80,
+ flagpole : true,
+ pivotPoint : [1,1,0] // Entire POI to the right of the pole
+ };
+
+ // (8.6) then create and add it to the scene
+ ogCreatePOI(poilayer, PoiDefinitionWithIcon);
+
// Create another poi layer to place poi's interactive
bycicleLayer = ogCreatePOILayer(world,"byciclelayer");

0 comments on commit f776360

Please sign in to comment.
Something went wrong with that request. Please try again.