How to customize one of the standard Google Maps API map types - google-maps-api-3

There are 2 options for base map in Earth Engine: Map (default) and Satellite. I would like to have Satellite as default base map when I press ctrl + enter (or click run button). I know that I can switch between the 2 options by clicking on the desired one, but I would like to make this automatic.
I tried:
Map.setOptions({
mapTypeId: "SATELLITE"
});
This almost does what I want expect that all labels and countries / administrative boundaries are turned off. How can I have both the satellite base map and these features?
I checked this, but I can't figure out how to achieve what I want.

Does this help:
Map.setOptions('HYBRID')
https://developers.google.com/earth-engine/apidocs/map-setoptions

Related

How to export here maps to image file for printing programmatically?

Just like leaflet and Arcgis JS Api have support for printing and exporting map to image files, how to do it in here maps? I explored here API and searched web but found nothing.
You have to take a look at our Map Image REST API.
https://developer.here.com/documentation/map-image/topics/what-is.html
What Is the Map Image API?
The HERE Map Image API is a REST API that allows you to request static map images for all regions in the world. The map images show conventional map views, but can also include points of interest, routes (for example, with turning points and junction views), statistics and heat maps.
In addition, the API offers a variety of supplementary services for displaying location-based data. For example, it is possible to present roadsigns.
You can also request the map images in different formats:
0 PNG
1 JPEG (default)
2 GIF
3 BMP
4 PNG8
-5 SVG (only for companylogo)
If this is not given, JPEG is used as default.
Within JavaScript, you can configure a MapTileService to request tiles of the map.
https://developer.here.com/documentation/maps/topics_api/h-service-maptileservice.html
There is a capturing functionality in HERE javascript API.
I made a quick draft how you can easily export the captured canvas element of the map with anything rendered on top of it:
// overlay element containing captured canvas element
var captureBackground = document.createElement('div'),
bgStyle = captureBackground.style;
bgStyle.width='100%';
bgStyle.position='absolute';
bgStyle.top='0';
bgStyle.bottom='0';
bgStyle.background='rgba(0,0,0,0.7)';
bgStyle.padding='30px';
bgStyle.zIndex=1000;
captureBackground.addEventListener('click', function(e) {
document.body.removeChild(this);
});
// capture the map:
map.capture(function(capturedCanvas) {
// remove previously added canvas from the overlay
captureBackground.innerHTML = '';
captureBackground.appendChild(capturedCanvas);
document.body.appendChild(captureBackground);
}, [], 50, 50, 700, 700);
For more information see https://developer.here.com/documentation/maps/topics_api/h-map.html#h-map__capture

Markers on map leaflet for shiny

Is there a way to set visible markers (plural) on a leaflet map, when a user clicks on this map in a shiny application? Furthermore, is it possible to retrieve the coordinates of this marker?
If not in shiny, can you do that in leaflet JS?
It is hard to be specific without any code, but here are the basics.
1) Shiny/Leaflet lets you subscribe to events such as mouse click. If your map is called MyMap you would use the code:
ClickVar<-input$MyMap_click
then ClickVar is a reactive variable - a list, that includes the lat, long and the layerId.
Now that you have the lat and long you can use that to add your popup. Do all of this in an observerEvent like so:
observeEvent( input$MyMap_click, {
ClickVar<-input$MyMap_click
addPopups(MyMap, lng=ClickVar$lng, lat=ClickVar$lat, popup="Here I am")
})
Note - I have not tested this so you may need to alter it slightly. You may also want to think about removing one popup when another is clicked, assigning them a layerID or group etc.

Google map how to display a dragable marker based on coordinates and return new coordinates

I have to write a script for Google Maps V3 which will do the following:
Place a marker on a map based on a set of coordinates and possbibly change the address after the page has been loaded
Allow the user the drag the mark to replace it elsewhere
Collect the new coordinates once the marker has been moved.
The first part is basic enough and should be fine, changing the address after the page is loaded should only be a matter of calling back the same function?
I am not sure where to start on the draggable marker and collecting hew coordinates.
Would anyone know of scripts / API's or where in the doc should I start?
Have you checked the Google Maps Javascript API V3 Reference to see whether the google.maps.Marker class has :
a draggable option
an dragend event
a getPosition method
Hint: The answer might just be "yes" to all three, and you don't need much else to solve your problem.

Using Google API v3 - administrative_area_level_2 tag

I'm using HTML to display a map area with a number of points/markers in it.
I use this function to 'pan' / move the map to see a specific place (list of places on the side of my web page).
function animate(lati,long) {
var latLng = new google.maps.LatLng(lati, long); //Makes a latlng
map.panTo(latLng); //Make map global
}
QUERY :- I've found in this website, a Google tag called "administrative_area_level_2"
https://developers.google.com/maps/documentation/geocoding/
From what i gather - this tag tells Google maps / API services to display the COUNTY area / borders (in USA at least & other countries).
However, when looking at maps.google.com & finding a USA county - the HTML source code is so confusing / jumbled.
Has anyone used this administrative_area_level_2 tag before to show a county border ? & are there any tutorials / examples of how to use it ?
Or is this tag something completely different ?
(Some of my markers are counties - but others are towns / cities).
From what i gather - this tag tells Google maps / API services to display the COUNTY area / borders (in USA at least & other countries)
This "tag" tells Google maps when used inside a request, that the response should be filtered to this component.
When returned within the response it tells you the type of the component .
This "tag" will not have any effect to the drawing of the map, and currently there isn't any implemented option to automatically draw any borders .

OpenLayers Vector Layer Maximum number of features

I was wondering if it is possible to limit the number of features you an draw on a vectorylayer. If I already have a polygon drawn, and go to draw another it will delete the first feature.
If not is it possible to add a listener to the vector layer, so that I can erase all features when clicking to draw?
Thanks!!!
You can't set max number of features on Vector Layer, but it has a whole lot of events where you can inject your own logic. Here are available events:
"beforefeatureadded", "beforefeaturesadded",
"featureadded", "featuresadded", "beforefeatureremoved",
"beforefeaturesremoved", "featureremoved", "featuresremoved",
"beforefeatureselected", "featureselected", "featureunselected",
"beforefeaturemodified", "featuremodified", "afterfeaturemodified",
"vertexmodified", "vertexremoved", "sketchstarted",
"sketchmodified", "sketchcomplete", "refresh"
You can use "beforefeatureadded" for instance:
your_vectror_layer.events.on({'beforefeatureadded': function(){
//Remove first feature or whatever you want to do
}});
you can make a button and when you click on it, it will remove all the features in your vector layer :
map.layers[1].removeAllFeatures();
Here 1 is the id of my layer (my vector layer is the second one after an OSM layer)
Good Luck !

Resources