In my KML I have an aggregate of placemarks in a table format. When you click the placemark you can see all the placemarks currently being loaded. Each of the placemarks have an id like below
<Placemark id="Location1">
When I add the following below I am able to fly to that balloon and it will open. However in the API this function does not work. It tries to do the following http://www.something.com#ballooonFlyTo is there a way to allow the balloon fly to method in the API?
<a href="#Location1;balloonFlyto>Location 1</a>
Not directly no, but it would be easy to modify your links to call a custom function that will support the behavior you require.
Also, if you are loading your features via kml rather than creating them programmatically then you would need to supply the full path to the kmlFeature - not just its ID. i.e.
http://somesite.com/my.kml#Location1 rather than just #Location1 - where http://somesite.com/my.kml is the file that defines the feature with the id Location1.
If you have something like the following javascript method it should work as expected. That is it will fly to the view and open a feature balloon. (This is presuming ge is the google earth plugin in your application and that the placemarks have abstract views defined).
// Attempts to find and element by ID,
// fly to its abstract view and open a feature balloon for it.
var flyto = function(id) {
var placemark = ge.getElementByUrl(id);
if(!placemark) {
return false;
}
if (placemark.getAbstractView()) {
ge.getView().setAbstractView(placemark.getAbstractView());
}
var content = placemark.getBalloonHtmlUnsafe(); // or getDescription()
var balloon = ge.createHtmlStringBalloon('');
balloon.setFeature(placemark);
balloon.setContentString(content);
ge.setBalloon(balloon);
return false;
};
Then you can simply modify your links to call the flyto function passing the desired id. e.g.
Location 1
If your placemarks do not have abstract views, then you would have to do something like extracting the point geometry and then create a lookat or camera using the latitude and longitude data to set the view.
EDIT
I decided that this functionality was really cool, so I have put together an example that does not require any special mark up of the links at all. When kml links containing a command are clicked the plugin behaves just like the full Google Earth Client would.
Here is a fully working example.
Related
I need to show homeCard() and after I need to show settingsCard() automatically. Since I coudn't find a right method in app-script documentation I need some help for do this task.
Here I provided the code
function nevigateToUserSelectionPage(e) {
var navigation = CardService.newNavigation();
var builder = CardService.newActionResponseBuilder();
var userSelectionCardNavigation = navigation.pushCard(settingsCard());
return builder.setNavigation(userSelectionCardNavigation).build();
}
function homeCard() {
builder = CardService.newCardBuilder();
section = CardService.newCardSection();
let participantsText = CardService.newTextParagraph()
.setText("<u>Home card here</u>");
let blink = CardService
.newImage()
.setImageUrl('https://res.cloudinary.com/deez2bddk/image/upload/v1646709349/icons8-dots-loading_x9q7jv.gif');
section.addWidget(blink);
section.addWidget(participantsText);
section.addWidget(AddSplah);
builder.addSection(section);
console.log('home card triggered!!!');
return builder.build();
}
function settingsCard() {
//const myTimeout = setTimeout(5000);
Utilities.sleep(10000);
builder = CardService.newCardBuilder();
section = CardService.newCardSection();
console.log('Settings card triggered!!!');
let participantsText = CardService.newTextParagraph()
.setText("<u>This is Settings Page....</u>");
section.addWidget(participantsText);
section.addWidget(getAuthenticationStepperImage());
builder.addSection(section);
return builder.build();
}
in code.gs file
function mainController() {
return homeCard();
}
Above code blocks I need to execute homeCard() function and then , settingsCard() but I can`t find a proper solution in workspace add-on creation documentation provided by google.
After doing some research, I think the CardService does not provide a method for non-interactive updates.
You can update the view based on user click interaction, as you can see in the Cats Quickstart. When the user clicks the cat image changes the image updates due the URL has a new parameter via new Date().getTime().
Apart from this, you have the triggers provided by Google, such as: homepageTrigger for common use case or onItemsSelectedTrigger specifically for Drive. You can review the full list here.
In summary: I think that what are you trying to achieve actually is not currently feasible within CardService.
If you wish Google adds some kind of time driven trigger to Google Workspace Add-ons, request it via this form.
Remember that in the actual state, HTML/CSS is not allowed, maybe this would be another possible path for your Feature Request.
As i am using folllowing code to load POI fro local
requestDataFromLocal: function requestDataFromLocalFn(lat, lon) {
var poisNearby = Helper.bringPlacesToUser(myJsonData, lat, lon);
World.loadPoisFromJsonData(poisNearby);
/*
For demo purpose they are relocated randomly around the user using a 'Helper'-function.
Comment out previous 2 lines and use the following line > instead < to use static values 1:1.
*/
//World.loadPoisFromJsonData(myJsonData); This line show only one POI
}
};
And I am also seeking help to reload POI from local
Use callCavaScript to pass information to JS environment and urlListener (document.location = "architectsdk://") to pass information to native code.
Have a look at these samples for more Information
Retrieving POI Data from Application Model
Native POI Detail Page
Best regards
We developed a web page where we are showing health facility locations of a country on a map. We used Leaflet for the map display. We actually do not need to display the online map tiles in the background. If we can only show a vector country map that would also be OK. I came to know that tiles can be downloaded and saved offline in Leaflet etc, but not interested in that direction.
What I want is available in this page
Where Leaflet is used but the world map online tiles are not displayed. But the code is quite complex to understand. Is there any easy example or guidance to do what I need?
This is actually quite easy when using a L.GeoJSON layer. First off you would need to find the correct GeoJSON for the region you want to display. For instance, here are some for the US: http://eric.clst.org/Stuff/USGeoJSON. Next create a map like you would normally do:
var map = new L.Map('map', {
'center': [0, 0],
'zoom': 0
});
Then you would need to fetch/load your GeoJSON data into your script using ajax via jQuery or something else and use that to initialize a GeoJSON layer and add that to your map:
// jQuery ajax request
$.ajax({
// url with your geojson data file
'url': 'my.geo.json',
// return json object, not as string
'dataType': 'json',
// on success handle result
'success': function (result) {
// Initialize GeoJSON layer and add to map
var layer = new L.GeoJSON(result).addTo(map);
// Fit map to bounds of your GeoJSON
map.fitBounds(layer.getBounds());
}
});
That's it. You can find lots of GeoJSON datasets online and if you want to know more about the L.GeoJSON i would recommend reading the reference i linked earlier and this tutorial: http://leafletjs.com/examples/geojson.html
I am working with the Google Web Toolkit wrapper for OpenLayers. I'm attempting to add a WMS layer to a map, but I need to parse a Capabilities document in order to get the available layer names. I see that a WMSCapabilities class is available in OpenLayers http://dev.openlayers.org/releases/OpenLayers-2.12/doc/apidocs/files/OpenLayers/Format/WMSCapabilities-js.html, but I can't seem to find the implementation in GWT. Is this feature not yet available, or is it hiding, undocumented somewhere? Thanks in advance!
I still don't know if the GWT implementation is available, but it's actually rather easy to wrap native javascript code in Java. Here is my solution:
import com.google.gwt.core.client.JsArrayString;
native JsArrayString getLayerNames(String capDoc) /*-{
var toReturn = [];
var parser = new $wnd.OpenLayers.Format.WMSCapabilities();
var doc = parser.read(capDoc);
for (var i in doc.capability["layers"]) {
toReturn.push(doc.capability["layers"][i].name);
}
return toReturn;
}-*/;
You can then access them using:
JsArrayString layers = getLayerNames(getMyCapabilitiesDocumentAsString());
for (int i = 0; i < layers.length(); i++) {
Window.alert("A layer name is " + layers.get(i));
}
The variable doc is a javascript array containing the entire contents of the capabilities document, so it's possible to access more than just the layer names; simply pull out what you need. Also, it's probably better to create a single parser rather than create a new one each time the method is called, but that's a different exercise ;)
I am working on a project that uses GWT 2.4 and gwt-maps.jar to create a MapWidget and place it in a panel with various controls. This all works fine.
I would like to give my users the ability to draw a polyline on the map and use the getLength method in Polyline to determine the length of the drawn polyline. I have done this before in ActionScript and it was a bit of a pain in the neck (the rubber-banding between the last clicked point and the mouse in particular) and I was hoping not to have to do that again.
The drawing manager looks like it might be a good fit (for the drawing part at least) but it is in v3 of the API and the gwt-maps.jar code only is at v2. So I thought I might write some JavaScript and call out from GWT using JSNI, something along the lines of (in wibble.html - my top-level HTML file):
var dM = new google.maps.drawing.DrawingManager( ...
function showDM(map) {
dM.setMap(map);
dM.setOptions({
drawingControl: true
});
And then (in Wobble.java):
private MapWidget map = new MapWidget( ...
private native void showIt(final MapWidget map) /*-{
$wnd.showDM(map);
}-*/;
I have tried passing the MapWidget and its peer but in both cases I get an invalid value error when calling setMap.
Has anybody tried (and succeeded) in doing this or am I barkig up the wrong tree?
Thanks,
SO
First of all, I only have experience with GWT and GWT-JS communication. Not Google APIs.
Now:
Looks like you are passing a GWT object (compiled javscript object) to DrawingManager. The problem is the DrawingManager API receives "nice javascript objects" (not objects with obfuscated methods).
If you want to pass an HTML Element is ok (but then, you must pass widget.getElement() that really is a <div> object (by example).
Solution
Indeed GMaps API docs says you must pass a Map object from the GMap API. You create that map with an element that will be the canvas.
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
If you want to use your MapWidget as the map canvas then you can use its HTML Element.
In GWT:
private native void showIt(final MapWidget map) /*-{
$wnd.showDM(map.getElement()); // use mapwidget's element as canvas
}-*/;
In javascript:
function showDM(canvasToUse) {
// TODO: define myOptions :)
var map = new google.maps.Map(canvasToUse, myOptions);
dM.setMap(map);
dM.setOptions({
drawingControl: true
});
Disclaimer
It's only based on my experience with GWT and JSNI. I didn't try it nor have experience with GMaps or DrawingManager. You should check what I say and tell me if I had luck :)
Hope it helps!