TTMSFMXWebGMaps map links return

Hi, when a user clicks on one of the small point of interest type icon links on the maps they see a pop up with info.  The user can then click on the "more information" link in the popup to see a web page with further information.

When the user does this there's no way to return to the web map view of the TTMSFMXWebGMap.

Is there a built in way or a code snippet that will allow the user to go back to the map?

Hi, 


The more information link is currently opened inside the webgmaps webbrowser instance. We will have to investigate if it is technically possible to intercept this and redirect the URL to open in safari instead. Currently there is no way to return to the map.

Kind Regards, 
Pieter

What happend with the solution?

In the latest release (1.8.0.3), you can implement the OnBeforeNavigate event and return cancel := true when a redirection occurs to a http formatted url, such as the link in the popup window:


procedure TForm47.TMSFMXWebGMaps1BeforeNavigate(Sender: TObject;
  var Params: TTMSFMXWebGMapsCustomWebBrowserBeforeNavigateParams);
begin
  if Params.URL.Contains('http') then
    Params.Cancel := True;
end;

Kind Regards, 
Pieter 

Thanks

The same event will allow me to cancel any "Popup Window" derived from the click over the map hot spots, like restaurants, gyms, or any other object inside de Map that retrieves Popup Windows?

I haven't taken a look at it, but at first sight, the popup window doesn't generate a OnBeforeNavigate event. I think it will require a javascript implementation that we will have to expose through the MapOptions property. We will investigate this here as soon as possible.


Kind Regards, 
Pieter

Thanks

I want to avoid any Popup window like the next image
 





Also How can I draw a circle over the TMSFMXWebGMap in the center, and this center remains the entire session of my program, I want this object be unamovable can you point me in the right direction please?

Does this update handle the  "more information" or "mas informacion" links that are shown in the information pop ups?


FYI Tested out the code posted above:

procedure TForm47.TMSFMXWebGMaps1BeforeNavigate(Sender: TObject;
  var Params: TTMSFMXWebGMapsCustomWebBrowserBeforeNavigateParams);
begin
  if Params.URL.Contains('http') then
    Params.Cancel := True;
end;

Works great - the "more information" links are disabled using this method.

Hi, 


In the latest version, you should be able to disable POI completely with the property MapOptions.DisablePOI. If you want POI to be visible but catch the more information url redirection you can use the beforenavigate as you already found out.

Kind Regards, 
Pieter

Hi Pieter, I have a small bug with this mechanism for disabling the POI clicks.


If I use the code snippet in the before navigate event:
  if Params.URL.Contains('http') then
    Params.Cancel := True;

The "more info" links are disabled as expected.  However if there's a street view image on the POI popup window then clicking on the street view image crashes my app.

Is there some additional code that I should use to make the street view image links safe?

------------

Also I'm trying a method to intercept the URL and use it in a separate TWebBrowser.  However I find that it's not working.  Note that my web map and web browser are on two separate TTabItem tabs on a TTabControl.  So I'm trying to slide to: hide the map, slide to a new tab, then navigate to the URL using a TWebBrowser.
What I'm seeing is that the tab slide works, but the WebMap remains visible.  Any ideas?

E.g.
procedure THeaderFooterwithNavigation.mapTripBeforeNavigate(Sender: TObject;
  var Params: TTMSFMXWebGMapsCustomWebBrowserBeforeNavigateParams);
begin
  if Params.URL.Contains('http') then
  begin
    WebMap.Visible := False;

    TabControl1.SetActiveTabWithTransition(TabWebBrowser, TTabTransition.Slide, TTabTransitionDirection.Normal);
    WebBrowser1.URL := Params.URL;

    Params.Cancel := True;
  end;
end;

Hi, 


It seems that the default FMX TWebBrowser is interfering with the way the TTMSFMXWebGMaps is showing. To display the URL on a separate tab, you can use the TTMSFMXWebBrowser in the TMS Pack for FireMonkey, or you can use another instance of the TTMSFMXWebGMaps.

TTMSFMXWebBrowser
procedure TForm1.TMSFMXWebGMaps1BeforeNavigate(Sender: TObject;
  var Params: TTMSFMXWebGMapsCustomWebBrowserBeforeNavigateParams);
begin
  if Params.URL.Contains('http') then
  begin
    TMSFMXWebGMaps1.Visible := False;

    TMSFMXWebBrowser1.URL := Params.URL;
    TMSFMXWebBrowser1.Visible := True;
    TabControl1.SetActiveTabWithTransition(TabItem2, TTabTransition.Slide, TTabTransitionDirection.Normal);


    Params.Cancel := True;
  end;
end;

TTMSFMXWebGMaps
procedure TForm56.TMSFMXWebGMaps1BeforeNavigate(Sender: TObject;
  var Params: TTMSFMXWebGMapsCustomWebBrowserBeforeNavigateParams);
begin
  if Params.URL.Contains('http') then
  begin
    TMSFMXWebGMaps1.Visible := False;

    TMSFMXWebGMaps2.URL := Params.URL;
    TMSFMXWebGMaps2.Visible := True;
    TabControl1.SetActiveTabWithTransition(TabItem2, TTabTransition.Slide, TTabTransitionDirection.Normal);


    Params.Cancel := True;
  end;
end;

Kind Regards, 
Pieter

Pieter Scheldeman2014-08-25 03:51:42

You will need to initialize the TMSFMXWebBrowser or the second TTMSFMXWebGMaps visible false, 

and toggle them as you switch pages in the tab. the visiblity is not automatically intercepted as both controls are real native Android controls and do not hook in to the FMX hierarchy.

Hi Pieter, this approach works nicely.  I can pop open "more info" links in the second TTMSFMXWebGMaps instance.


But... there's still an issue with the streetview link on the info pop up.  I'm seeing "NaN is not a valid integer value" errors popping up.  The debugger shows that happening when the Params.URL is:

'jsevent://streetviewmove:lat=43.667459#lng=-79.39361100000002#x=365#y=372'

To recreate the error click on a map POI to open an info popup on the map.
If there's a streetview image click on it.  The NaN errors will show up immediately.  There's usually 4 of the errors in a group.

Is there a way to filter out the streetview requests specifically?

FYI - when clicking on the streetview there's the NaN errors, and then the streetview is correctly displayed.

So the map function seems to be working but there's an unhandled exception in there somewhere.

I will investigate this as soon as possible.

Hi, 


We have investigated this here and have applied a fix for this, the next version will address this issue. If you wish to have an incremental source update, please contact us by email.

Kind Regards, 
Pieter