When using the following code I only see markers, not clusters.
Any help would be greatly appreciated.Unfortunately there is no demo for Clusters in the TTMSFMXWebGMaps demos and the VCL one crashes.
GMap.Clusters.Clear;
GMap.DeleteAllMapCluster; GMap.MapPanTo(GMap.MapOptions.DefaultLatitude,GMap.MapOptions.DefaultLongitude); GMap.MapOptions.ZoomMap:=2; if not Query.IsEmpty then begin while not Query.EOF do begin if LastCountry<>Query.FieldByName('Country').AsString then begin GMap.Clusters.Add; GMap.Clusters[GMap.Clusters.Count-1].Cluster.MinimumClusterSize:=1; GMap.Clusters[GMap.Clusters.Count-1].Cluster.Title:=Query.FieldByName('Country').AsString; LastCountry:=Query.FieldByName('Country').AsString; end; Marker:=GMap.Markers.Add; Marker.Latitude:=Query.FieldByName('Latitude').AsFloat; Marker.Longitude:=Query.FieldByName('Longitude').AsFloat; Marker.Cluster:=GMap.Clusters[GMap.Clusters.Count-1].Cluster; Query.Next; end; end; for I:=0 to GMap.Clusters.Count-1 do GMap.CreateMapCluster(GMap.Clusters.Cluster);
- We are not aware of any issues with the MarkerClusterDemo in VCL. Can you please make sure you assigned an API Key for both TWebGMaps and TWebGMapsGeocoding?
- Please note that this line "Marker:=GMap.Markers.Add;" shouldn't automatically add Markers to the map so you need to add the line "GMap.CreateMapMarker(Marker);" as well. With this change your code is working as expected when tested here.
Thanks. It was the GMap.CreateMapMarker(Marker) that cured my problem thanks. There is no problem with theVCL demo, I had just not assigned my API key to both controls.
I want to assign a value to the Cluster tag property, and then use that as displayed total on the Cluster. Can you please tell me how to do that?
Although there is no built-in way to change the Cluster value in TTMSFMXWebGMaps, the Calculator property indeed provides a way to change the Cluster value by using JavaScript.
Note that in JavaScript only the JS Cluster object is available, the Delphi Cluster.Tag property value is not part of this object.
I'm obviously doing something wrong as if I just add the function as specified in the documentation without any change, I get markers displayed instead of clusters. Any help would be grealy appreciated.
The Data property also is not accessible. Note that in JavaScript there is only access to the Google Maps Marker object which is different from the Delphi Marker object.
That doesn't seem to help me much. Can you suggest a way that I might be able to do this? I need to assign a value to each marker and when a cluster is displayed add up all of the marker values and display that.
Without making changes to the source code I can only suggest the following: If you don't mind the value appearing on the marker as well you could use the Merker.Title or Marker.Text properties which correspond with markers[].title and markers[].text respectively in the JS markers object.