using WebGMaps component:
When polyline clicked CurrentLocation always shows 0,0 so infowindow in code below shows at lat,lng 0,0. Is there another way to get the lat,lng where polyline clicked?
var
curLat, curLng: Double;
script: string;
begin
curLat := map.CurrentLocation.Latitude;
curLng := map.CurrentLocation.Longitude;
script := 'var infoWindow = new google.maps.InfoWindow({';
script := script + 'content: ''my info window'',';
script := script + 'position: new google.maps.LatLng(' + floattostr(curLat) +
',' + floattostr(curLng) + ')';
script := script + '});';
script := script + 'infoWindow.open(map);';
showmessage(script);
map.ExecJScript(script);
Hi,
Just figured out that GetLocation must be called 1st because it sets the current lat,lng and then can be read by map.CurrentLocation. So now getting realistic lat,lngs but info window still not appearing where polyline clicked. It's always showing in a corner of map. However the content of infowindow accurately reflects the data associated with the polyline that was clicked.
Also just ran a test in the Click event of the map as per code below and Latitude <> curLat and Longitude <> curLat . Why are these values different?
procedure TForm1.mapMapClick(Sender: TObject; Latitude, Longitude: Double;
X, Y: Integer; Button: TMouseButton);
var
curLat, curLng: Double;
begin
map.getCurrentLocation;
curLat := map.CurrentLocation.Latitude;
curLng := map.CurrentLocation.Longitude;
Please note that the resulting coordinates of the GetCurrentLocation call are based on your current IP address. I would expect that that these coordinates are different from the location where the map was clicked.