Detect which poi is clicked in mapquest flash - actionscript-3

So i am trying to get a workaround solution on the problem of mobile mapquest not supporting infowindows with flex components. i managed to create a custom handler for the pois. however i cant figure out how to detect which poi was clicked. all the pois are stored in a shapecollection and i would like to be able to detect which was clicked in order to push its data to another view. any ideas?

after a few days researching and trying different methods i found the solution within the flex itshelf. So here is my solution and I hope that more people can use this to their mobile apps.
var p: Poi = new Poi(myLatLng);
p.key = "myKey";
p.addEventListener(MouseEvent.CLICK,this.onPoiClick);
private function onPoiClick(e:MouseEvent):void {
var poi: Poi = e.currentTarget as Poi;
trace("The Poi's key is: " + poi.key);
}
Special thanks to the mapquest forums for helping out

Related

load 2D & 3D forge viewers in single web page

I would like to link between elements from the 2D sheet and 3D model, so when I select the element from 2D it should reflect and select (isolate) in the 3D also if I change the color it does the same on both e.g. and the other way around.
so I can use the document browser extensions to open the 2d sheet on 1st viewer and the 3d model on the 2nd viewer:
const firstModel = new Autodesk.Viewing.Private.GuiViewer3D(document.getElementById('MyViewerDiv1'));
const secondModel = new Autodesk.Viewing.Private.GuiViewer3D(document.getElementById('MyViewerDiv2'));
Autodesk.Viewing.Initializer(options1, function() {
viewer1.start();
viewer1.load(...);
});
Autodesk.Viewing.Initializer(options2, function() {
viewer2.start();
viewer2.load(...);
});
if the example above is correct I am still missing how to links both viewers.
I hope someone could help me with this issue
Note that we have a viewer extension that might already give you what you're looking for: https://github.com/Autodesk-Forge/forge-extensions/blob/master/public/extensions/NestedViewerExtension/README.md.
If you want to implement the cross-selection between two viewer instances yourself, you can. Just subscribe to the SELECTION_CHANGED event in one of the viewers, get the selected IDs, and select the same IDs in the other viewer using the usual viewer.select([...]); method.
Btw. regarding your code snippet:
the Autodesk.Viewing.Initializer only needs to be called once per the entire webpage
the Autodesk.Viewing.Private.GuiViewer3D instances should be created after the initializer has done its work

Geo Location on click _ Forge viewer

i'm looking for some guidance on how best to display real world coordinates when i click on the screen or select a model element in the forge viewer.
i have had a look around and done some research but with little success, however i have found this post that helps however the coordinate read out seems to be completely diffent to the cordantes that i would expect to see.
https://github.com/apprentice3d/ForgeViewerExtensions/blob/master/assets/js/extensions/transformationExplorer.js
As you can tell i dont know much about the viewer geo extension, any guidance on this would be great.
Thanks Tom.
If it's enough to get the world coordinates of a point you clicked on in the viewer, you can simply use the viewer's clientToWorld method, for example like so:
viewer.container.addEventListener('click', function (ev) {
const result = viewer.clientToWorld(ev.clientX, ev.clientY);
if (result) {
console.log(result.point);
}
});
i managed to get it to work by using NOP_VIEWER.model.getData().globalOffset
Example
this.infoX.innerText = nodeData.position.x + NOP_VIEWER.model.getData().globalOffset.x;

forge Viewer - Markup camera change issue

In my viewer, I have a markup plotted using cloud mode and during camera change event, am not able to map the associated label with the markup as it moves on.
To make this work I store coordinates and while camera change event I use worldToClient to find the new coordinates, but this is not working
So problem is with finding original world coordinates. I tried multiple ways as below, but nothing seems to work for me. Much appreciate help on this. Just for an idea on this, am attaching screen-shots of model before and after camera change.
/*** option 1***/
worldCoord = markup.markups[0].generateBoundingBox().max;
/*** option 2***/
var coords = viewer.impl.clientToViewport(pos.x, pos.y);
worldCoord = coords.unproject(viewer.impl.camera)
/*** option 3***/
worldCoord = markup.markups[0].getClientPosition()
/*** option 4***/
worldCoord = viewer.clientToWorld(pos.x,pos.y,true);
/***option 5***/
worldCoord = markup.markups[0].getBoundingRect()
Finally I got it.
We can store layername info with your label and fetch it in your camera change event using below code.
position = markup.svgLayersMap[layerName].markups[0].getClientPosition()
hope this helps someone

how to change a CesiumJS viewer's baselayer url

i am using a CesiumJS instance to display a base map of the earth using a imageryProvider from source A.
var viewer = new Cesium.Viewer('cesiumContainer', imageryProvider:providerA);
Now while using the Viewer I would like to be able to change this map to get images from providerB at a certain event.
I tried:
viewer.scene.imageryLayers.get(0).imageryProvider.url = providerB.url
However that does not seem to work and also feels quite like hack anyway.
I could not find anything in Cesium's documentation .
Is this at all possible without restarting / recreating the viewer instance?
I know that there is a Cesium.BaseLayerPicker (https://cesium.com/docs/cesiumjs-ref-doc/BaseLayerPicker.html)
However I do not see what method this picker calls on "select" )
Thanks a lot.
The BaseLayerPicker widget calls this code when the user selects a new layer.
There's a lot of boilerplate widget management in that block of code, but for your sake, only a couple of the lines are critical. First, the old existing active imagery layer is searched for, and removed:
imageryLayers.remove(layer);
Then, a new imagery provider is constructed and added at index 0, the first position, which is the base imagery layer:
imageryLayers.addImageryProvider(newProviders, 0);
You can directly change the URL of the provider but you should also change appropriate parameters("layers" in case of WMS, "layer", "style", "format", "tileMatrixSetID " ... in case of WMTS) depending on the type of provider(WMS or WMTS).

Map pinning in react native

I am looking for a way to capture user click and create a pin on the map view. Does anyone has any idea where can I start, I was not able to find anything.
There are two solutions for your issue.
Using RN's native MapView component, there are no easy solutions. You can create a pin when `onRegionChangeComplete is triggered. But you'll get the coordinates of the center of the map only. I've set up a running example for you here.
You can use this very well done package. In this package, there is an onPress method that you can use. It'll return you the coordinate of the point you just pressed.
You should look at the onRegionChange prop from the MapView component. That's a function that will be triggered whenever the user drags the map. Between that and the annotations props you should be able to achieve what you want.