1

Trying to follow the steps https://forge.autodesk.com/blog/add-mapbox-google-maps-forge-viewer but i can't place the model correctly on the map.

I am running the functions listed here: https://learn.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system:

  1. LatLongToPixelXY(latitude, longitude, 7, out pixelX, out pixelY);

  2. PixelXYToTileXY(pixelX, pixelY, out tileX, out tileY);

  3. The result pixelX = 16225, pixelY = 12249, tileX = 63, tileY = 47.

  4. I substitute the previous values:

    map.position.set(16225,12249,-45); class MapPlaneNode extends MapNode { constructor(parentNode = null, mapView = null, location = MapNode.ROOT, level = 7, x = 63, y = 47)

The result is that the model comes out small and not positioned correctly. In the image, the red arrow is where the model is inserted, and the green arrow is where it should be.

image of result

What am I doing wrong?

Thank you very much

2 Answers 2

0

Positioning the model is a little tricky.

In the demo I created, I originally used world coordinates, where I set the root tile as level 0, and used the correct lat/long coordinate utils function to position the revit model in the correct location. Unfortunately, the precision caused a rendering problem with the post-renderer (line edges were missing, and some strange z-fighting precision issues)... so, I decided to hack the level, and move the map into the position I wanted and center the revit model at origin 0,0,0.

This made things a lot more manual and rather tricky, but it got around the rendering issue and also limited the user into a small area in the world, which I preferred.

I suggest changing the root tile back to zero, and adjusting the model position globaloffset to the value of the lat/long W84 utils. See the blog post and also the coordinates section of the geo-three repo, for more details here: https://github.com/tentone/geo-three#coordinates

1
  • Is there a way to create a smaller mesh with only a portion of the map? At the moment it's about 90 miles long each side, which is not very practical and impacts the navigation. 1 mile x 1 mile would be plenty for my project.
    – Duzmac
    Aug 4, 2021 at 7:56
0

Found a trick to adjust the map. It is still manual but it's fairly quick:

  1. Calculate Tile X and Y (you did that step already, it's just for reference):

Copy the TileSystem class from the the link bing-maps-tile-system you posted into https://dotnetfiddle.net/ (you'll also need to add: using System.Text)

Change the main as follows

public static void Main()
{
    int pixelX, pixelY, tileX, tileY;

    TileSystem.LatLongToPixelXY(YOUR LAT HERE, YOUR LONG HERE, 7, out pixelX, out pixelY);
    Console.WriteLine("LatLongToPixelXY: " + pixelX.ToString() + ", " + pixelY.ToString());
    TileSystem.PixelXYToTileXY(pixelX, pixelY, out tileX, out tileY);
    Console.WriteLine("PixelXYToTileXY: " + tileX.ToString() + ", " + tileY.ToString());
}

This will give you the TileX and Tile Y that you'll need to replace in the Extension.

  1. Calculate Position

In the Extension set the X, Y position to 0,0, and the adjust the Z so that the map is below your model

map.position.set(0, 0, z);

Run the Extension and see where your project lands on the map. Now locate this landing point in Google maps (I found it useful at this stage to search the map using a corner between two streets by entering for example: Parker St & Wilson Rd). When you've found it, click on the landing point in Google map to place a Marker, then right-click on the marker and select Measure Distance. You will have to measure the distance to your destination both vertically, and horizontally (not directly to it). For example you'll get dH = 43.5km and dV = 17.8km

And this is were the magic happens: Multiply both numbers by 3400 if your distance is in km (or by 2113 if you distance is in miles) and set the position with those values:

dH * 3400 = 147900

dV * 3400 = 60520

If your destination is to the E or S use positive values. If your destination is to the W or N use negative values

map.position.set(147900, -60520, z);

Now it won't be perfect, but it'll be close enough to finish adjusting the value manually.

1
  • 1
    I updated my blog post - it now points to your answer. Thanks Duzmac. This is AWESOME! Aug 5, 2021 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.