I've googled, looked through S.O., and even just ran through the javascript properties using firebug, but I just can't find a way to get the maxIntensity property in a google heatmap. I can set maxIntensity, when instantiating the new map.
According to the docs here: https://developers.google.com/maps/documentation/javascript/3.10/reference#HeatmapLayer
there's no method for getting to the heatmap options object either, just setting as well.
Any ideas?
You can get it, assuming heatmap is the heatmap layer:
heatmap.get('maxIntensity')
First, would suggest taking a look at the Google Maps Documentationj. The provided solution seems correct, you can double check with the
heatmap section.
let heatmap = new google.maps.visualization.HeatmapLayer({
data: locations,
map: map,
maxIntensity: maxI,
radius: rad,
opacity: opac
});
Related
I have the following piece of code to create a heatmap layer on a Google map:
Please, see https://pastebin.com/MrGVevxj
but it doesn't show any heatmap overlay on the map. However, the following example code works like a charm:
https://pastebin.com/87TDrGAq
Can you tell me what I'm missing here?
I'm answering my own question. The problem was with the size of the points to render the heatmap due to the different scales between the maps. For instance, the following value shows the heatmap:
var markersX13749 = new google.maps.visualization.HeatmapLayer({
data: markersX13749Data,
dissipating: false,
radius: 0.7
});
In the apparently non-working piece of code, I was using the value 0.003 for the radius which is too small.
I am writing a google heatMap application and I need to delete the data which heatmap layer contains. Is there some solution? I went trough all stack overflow and can not find the proper solution. Everywhere they advise to do something like this:
heatmap.setMap(null) but this only hides the map, and when I do heatmap.setMap(map) the layer appears again
You can't delete a variable in javascript but you can assign as undefined
heatmap = undefined;
so heatmap is not a valid object
You can easily just set the data to an empty array
heatmap.setData([])
heatmap.setMap(this.map)
I load data for my Google Maps v3 with GeoJSON:
that.map = new google.maps.Map($('#map')[0], mapOptions);
that.map.data.loadGeoJson('http://localhost/geoserver/...');
Now, at some point on some user event I need to get one marker and paint it blue.
I can set different color with setIcon.
My idea is to get all features, then iterate through them, find the right feature (based on UNIQUE feature data field) and find marker behind that feature and change icon. I found some approaches that store all markers in array, but don't know why I need another array. Computer resources are important and I don't want to duplicate things.
I need help with, how to get features and how to get Marker object associated with selected feature. If there is a better way to do it, please...
UPDATE
I found this:
var feature = this.map.data.getFeatureById(ID);
I just need to get feature Marker. How? Doesn't look that Feature class has method for that?
There is no method/property that gives you access to the shape(marker,polygon,etc.) that has been created by the API.
To set a new icon-property for a particular feature use overrideStyle:
map.data.overrideStyle(feature, {icon: newIconSettings});
Another option is:
that.map.data.setStyle(function(feature)
{
var color = 'red';
if (feature.getProperty('color'))
{
color = feature.getProperty('color');
}
return ({ // #type {google.maps.Data.StyleOptions}
icon: 'http://maps.google.com/mapfiles/ms/icons/' + color + '-dot.png',
});
});
But it is not as good as Dr. Molle solution, because it needs to iterate through entire features set. I found it on google api documentation (look for title Change Appearance Dynamically).
I need to be able to put text within my polyline like the embedded Google Maps does as you can see from the below screenshot...
Now I have looked through the PolylineOptions API Reference and the Polyline but I can't see anything the points to achieving this. I really hope this is possible and I'm not going to have to hack something together.
Here is a Post Worth look at, Describing how to add labels to polylines:
http://duncan99.wordpress.com/2013/02/28/google-maps-api-polylines-and-events/
I commented yesterday asking if there might be any current way to add text within polylines. I know this question has been resolved, but the last activity I can see was in 2014.
I came across this library in github https://github.com/googlemaps/js-map-label
It allows a user to overlay text on the map with (see also examples folder):
var mapLabel = new MapLabel({
text: 'Route name',
position: pointCoordinate,
map: map,
fontSize: 12,
align: 'left',
});
Note, their source code within the "onAdd" method applies the pane to the map level, meaning the text would be underneath polylines. So, instead, I added it to the floatShadow pane by:
panes.floatShadow.appendChild(canvas);
Instead of:
panes.mapPane.appendChild(canvas);
I was able to make my map look like:
Adding text to polylines is not (currently) supported by the Google Maps Javascript API v3. You will need to create your own custom overlays to implement that. (I doubt you can make the text "follow" the polyline along a curve easily)
I have many different KML layers on a Google Map (v3). Random colors of markers were assigned to each set of markers. I would like to be able to control this, however.
So far, this is what I have:
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var kmlLayerOptions = { preserveViewport: true, suppressInfoWindows: true };
var Layer1 = new google.maps.KmlLayer('http://myurl.com/1.xml', kmlLayerOptions);
Layer1.setMap(map);
var Layer2 = new google.maps.KmlLayer('http://myurl.com/2.xml', kmlLayerOptions);
Layer2.setMap(map);
I need to be able to say I want Layer 1 to use blue markers and layer 2 to use red markers, but I can't seem to figure this out.
From what I can tell, there is no way to do this with the kmlLayerOptions, which is where it would seem like it would happen, so I don't see where else I could logically make this change other than directly on the layer object.
You can't change it with KmlLayer (at least currently, you could create an Enhancement request to add the functionality).
You can do it with FusionTablesLayers (import your KML into FusionTables, then use either the User Interface to set the icons or dynamic styling in the Google Maps API v3 (assuming you need less than 5 different icons, and the ones you want are available in FusionTables).
A final option would be to edit the existing KML to use the icons you want.
The KmlLayer renders according to the styling in the KML document itself, and you cannot override this in any layer options.
If you don't want to modify the KML itself, you could use a third party library such as http://code.google.com/p/geoxml3/ to render the KML on the clientside rather than having Google's servers render it, and this would give you the ability to override the rendering defaults.