react-google-maps OverlayMapType support - google-maps

I'm trying to implement an ImageMapType as an overlay using react-google-maps. This works fine on vanilla Google Maps as per the documentation.
However with this library, there is no overlayMapTypes array in the returned map object. Below is a code snippet adapted from the demo website:
handleMapLoad(map) {
this._map = map;
this._navOverlay = new google.maps.ImageMapType(NAV_OVERLAY_OPTIONS);
this._map.overlayMapTypes.push(this._navOverlay);
}
// throws error 'Cannot read property 'push' of undefined'
I did find an overlayMapTypes array inside map.context.__SECRET_MAP_DO_NOT_USE_OR_YOU_WILL_BE_FIRED but I have a feeling I shouldn't be using that.
So how do I do it?

If it is not there, then you can
a) Use the private values as a temporary solution
b) Develop an expansion of the library and make a pull request there. This is very similar to a, but when you are developing "inside" the library, now you have proper access.

Related

Forge Viewer 7.71 throws errors when removing and recreating custom meshes in ModelViewer

I have an application that adds many custom meshes to the Forge Viewer using the ModelBuilder extension. This application has worked for quite a while but ran into issues with version 7.71 of the viewer.
When graphics are updated in my application, I remove all existing meshes and then recreate them based on new data. With version 7.71 of the viewer, when I recreate the meshes I get many instances the following error in the dev tools console:
Uncaught TypeError: Cannot read properties of undefined (reading 'material')
at FragmentList.getMaterial (FragmentList.js:760:1)
at FragmentList.getMaterialId (FragmentList.js:754:1)
at RenderBatch.js:222:1
at Int32Array.sort (<anonymous>)
at RenderBatch.sortByMaterial (RenderBatch.js:220:1)
at RenderModel.applyVisibility (RenderModel.js:388:1)
at RenderModel.nextBatch (RenderModel.js:360:1)
at RenderScene.reset (RenderScene.js:387:1)
at Array.cmdBeginPhase (Viewer3DImpl.js:1125:1)
at RenderCommandSystem.executeCommandList (Viewer3DImpl.js:847:1)
After these errors, the new meshes are not created.
The release notes don't mention anything about any expected changes here. Looking for guidance from the Autodesk team.
Here is a repo that reproduces the issue:
https://github.com/bencameron/custom-mesh-refresh
I'm told it will take some time to implement the fix (ticket id LMV-6757). In the meantime you could stick with v7.70 or try these workarounds a colleague suggested:
1.) If all of the custom geometry is removed, like it is in the example app, it's probably simpler to remove the model entirely and start with a new one. Here is an (untested) snippet to do that:
// Instead of deleting all geometries individually, simply delete the model and create a new one
viewer.unloadModel(modelBuilder.model);
// drop the reference to the model builder instance, i.e. assign a new instance
modelBuilder = await sceneBuilder.addNewModel({});
// start adding the geometry again...
...
2.) If option #1 doesn't work, or if the user doesn't want to delete all geometries, they could also avoid the crash by running this snippet right after adding new geometries (i.e. every time they add a batch of geometries):
const scenes = modelBuilder.model.getIterator().getGeomScenes();
for (let i = 0; i < scenes.length; ++i) {
scenes[i].numAdded = 0;
}
I would recommend the first option over the second one if applicable.

Flutter for web - how use Chrome Api?

I am creating my first Flutter app for web. I need using Chrome api. For example I need to use it:
chrome.runtime.onInstalled.addListener
or
chrome.tabs...
but unfortunately I did not find any information about it.
Is it possible?
Yes, the chrome.* APIs are JavaScript just like all the other web APIs, so you can use Dart's JS support.
That means using Dart's js library.
For example, you could bind a function something like this (untested, without any type annotation, just an example)
#JS('chrome.runtime.onInstalled.addListener')
external void addInstalledListener(Function callback);
Edit:
If you'd rather pull in a dependency than roll your own, you can use something like chrome.dart.
import 'package:chrome/chrome_app.dart' as chrome;
void main() {
chrome.runtime.getPlatformInfo().then((Map m) {
print(m.toString());
});
}

MapBox: How do I create a featureCollection programmatically?

I want to create clutering in my map. When looking at guides and in the Docs, the FeatureCollection Json is always pulled from some external link. But how do I just create it programmatically as I read data from my server? I don't have it all ready in one place and it will always be changing anyway depends on the user.
I've been stuck with this issue before and ended up using some duck tape solution, but it won't work now. Can anyone please shed some light on this please?
You're able to create a FeatureCollection using an existing Feature object or array/list of Feature objects. This could be turned into a method that you could use to generate a new FeatureCollection whenever you receive a new dataset.
Given the information that you've provided, I am going to have to make some assumptions here - I hope that the following code snippet helps guide you in the right direction:
public FeatureCollection getFeatureCollectionFromCoordinateList(List<Coordinate> coords) {
List<Feature> pointsList = new ArrayList<>();
for (Coordinate coord : coords) {
Feature feature = Feature.fromGeometry(Point.fromLngLat(coord.getLongitude(), coord.getLatitude()));
pointsList.add(feature);
}
return FeatureCollection.fromFeatures(pointsList);
}
In the above example, the object I've used to represent data from the server is called Coordinate which I've given a getLatitude() and getLongitude() method to demonstrate using latitudinal/longitudinal information to generate a Mapbox FeatureCollection from a List of Feature objects which are created using the Feature.fromGeometry() method, passing in a Point.fromLngLat().
Please note that this mightn't be the best way to go about what you're trying to achieve here. That said, I hope it illustrates another way in which you can instantiate of FeatureCollection without reading in a JSON data source.

nativescript-google-maps-sdk use native calls to style the map

I successfully integrated a google map at my angular2+nativescript project. Everything I needed from the typescript definition file is working for me.
However, I wanted to play around with the styling of the map. AFAIK, I have to use native calls to the map, as the method setMapStyle() is not in the typescript definition.
I thought I could use the gMap property to access the native object and call the method. But I fail in setting up the right parameter as requested in google docs (https://developers.google.com/maps/documentation/android-api/styling) as I dont know how to create a MapStyleOptions object. The type is unknown.
Anyone tried or succeeded in this task yet and want to share some hints? How would you access native GoogleMap?
NativeScript allows you to access all public API of plugins used in the app, therefore you should be able to make native calls to the Map API as per the documentation at nativescript.org
If you want to create a MapStyleOptions object for example, you'd write
var MapStyleOptions : any = com.google.android.gms.maps.model.MapStyleOptions;
var mapStyle : any = new MapStyleOptions({"..":".."});
or just var mapStyle = new com.google.android.gms.maps.model.MapStyleOptions({"..":".."});
When TypeScript complains about com.google... not being recognized, you can either define it as any or import some ready to use typings.
Good luck!

best way to fix inspection for soapclients in phpstorm

I'm using PHPStorm v3 and have some code which connects to a certain SOAP service. (via a simple PHP SoapClient) No problems whatsoever. But the PHPStorm inspector cant find the methods available of the WSDL and thus cant recognize the used methods:
$this->soap = new SoapClient('somewsdl url');
$issues = $this->soap->getIssuesFromJqlSearch($this->auth,
'ticketId = '.$ticket->getId().'
AND impId ~ "'.$currentImplementation->getIdentifier().'"', 1);
Everything works but the method 'getIssuesFromJqlSearch' which is provided by the external WSDL is highlighted with the mentioning of an undefined method... How can i 'tell' PHPStorm what should/could be used (or explain how to parse the WSDL?)
You can suppress the inspection for this statement from the Alt+Enter, right arrow menu:
This is not perfect, since it does not parse the WSDL and you have to do it manually, but works fine after the initial setup.
Create a class extending the native SoapClient and use annotations to add virtual methods:
/**
* #method mixed getIssuesFromJqlSearch
**/
class VendorSpecific extends \SoapClient {}
Or you could generate such client yourself, implementing all the methods as a proxy to self::__soapCall(). See my SoapClient generator for reference. The upside is that it can parse the WSDL, though not perfectly.