Jump to content

Google Maps for uniGUI


lema

Recommended Posts

Dear All,

 

Can teach me how to use this component in UNIGUI, ?

 

1. retrieve the postal code from the address.

2. Calculate the distance between two address.

 

Thanks in advance.

 

Hello,

 

1. You can try reverse geocoding.

 

2. Use the included Haversine formula

function TUniGMap.ComputeDistanceBetween(lat1, lng1, lat2, lng2: Double): Double;

Link to comment
Share on other sites

Hi Lema,

 

when I Compile my projects to 64 bits the UniGmap only shows a white screen. :unsure:

 it runs well on 32 bits but I really need to compile to 64 bits.

I'm using Delphi Berlin update 1 and unigui version

 

Hello,

could you please upload a sample application demonstrating the problem ?

Link to comment
Share on other sites

Hello,

could you please upload a sample application demonstrating the problem ?

 

Hi Lema, Yes I can, I send you a link, its a simple project

 

https://1drv.ms/u/s!Armx7bQj2c-RiNodsEppJqJX-HktXQ

 

also I have some problems running project as ISAP dll published to IIS, even in 32 bits I get a white screen instead of the map,

I tested you demo project and have the same problem

I sent you some pictures in the links below

 

https://1drv.ms/i/s!Armx7bQj2c-RiNob_Zo6gft6UK-CBA

 

https://1drv.ms/i/s!Armx7bQj2c-RiNoc4_Dw7spMS3ze3g

 

 

 

 

 

Link to comment
Share on other sites

Hi Lema, Yes I can, I send you a link, its a simple project

 

https://1drv.ms/u/s!Armx7bQj2c-RiNodsEppJqJX-HktXQ

 

also I have some problems running project as ISAP dll published to IIS, even in 32 bits I get a white screen instead of the map,

I tested you demo project and have the same problem

I sent you some pictures in the links below

 

https://1drv.ms/i/s!Armx7bQj2c-RiNob_Zo6gft6UK-CBA

 

https://1drv.ms/i/s!Armx7bQj2c-RiNoc4_Dw7spMS3ze3g

 

Hello, did you set your own Google API Key ?

(The corresponding constant is MyGoogleAPIKey)

 

You can get your key at https://code.google.com/apis/console/

 

Link to comment
Share on other sites

Hi Lema,
 
after installing version 1.4.8 (with unigui Pro uni-1.0.0.1403), the route function displays an error and does not work.
The error also comes with uniGMap Demo (I've compiled on my PC)
If I open the DIRECTIONS example and click on GO, the application shows a script error with the "Unexpected string" message and the following text:
 
MarkerClusterer_OE4.clearMarkers();for ( var i=0; i<markersArray_OE4.length; i++ ) {google.maps.event.clearInstanceListeners(markersArray_OE4);markersArray_OE4.setMap(null); } markersArray_OE4.length = 0;if (typeof directionsDisplay != "undefined") {  directionsDisplay.setMap(null);};var rendererOptions = {draggable: true};directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);var directionsService = new google.maps.DirectionsService();  var request = {   origin                   : "Brussel",   destination              : "Maastricht",   travelMode               : google.maps.DirectionsTravelMode.DRIVING,   unitSystem               : google.maps.UnitSystem.METRIC,   waypoints                : [],   avoidHighways            : false,   provideRouteAlternatives : false,   avoidTolls               : false};  directionsService.route(request, function(response, status){  if ( status == google.maps.DirectionsStatus.OK ) {    directionsDisplay.setDirections(response);    directionsDisplay.setMap(gm_OE4);  } else {alert(status);}});  google.maps.event.addListener(directionsDisplay, "directions_changed", function() {  var steps = [];  var wp    = [];  var my    = directionsDisplay.getDirections();   var data  = {};  data.copyrights     = my.routes[0].copyrights;  data.distancetext   = my.routes[0].legs[0].distance.text;  data.distancevalue  = my.routes[0].legs[0].distance.value;  data.durationtext   = my.routes[0].legs[0].duration.text;  data.durationvalue  = my.routes[0].legs[0].duration.value;  data.startaddress   = my.routes[0].legs[0].start_address;  data.endaddress     = my.routes[0].legs[0].end_address;  data.startlocation  = {"lat": my.routes[0].legs[0].start_location.lat(),"lng":my.routes[0].legs[0].start_location.lng()};  data.endlocation    = {"lat": my.routes[0].legs[0].end_location.lat(),"lng":my.routes[0].legs[0].end_location.lng()};  for ( var i=0; i < my.routes[0].legs[0].steps.length; i++) {    steps.push({      "enc_lat_lngs"   : my.routes[0].legs[0].steps.encoded_lat_lngs,      "instructions"   : my.routes[0].legs[0].steps.instructions,      "distancetext"   : my.routes[0].legs[0].steps.distance.text,      "distancevalue"  : my.routes[0].legs[0].steps.distance.value,      "durationtext"   : my.routes[0].legs[0].steps.duration.text,      "durationvalue"  : my.routes[0].legs[0].steps.duration.value,      "startlocation"  : {"lat": my.routes[0].legs[0].steps.start_location.lat(),"lng": my.routes[0].legs[0].steps.start_location.lng()},      "endlocation"    : {"lat": my.routes[0].legs[0].steps.end_location.lat(),"lng": my.routes[0].legs[0].steps.end_location.lng()}    });  }  data.steps = steps;  for ( var i=0; i < my.routes[0].legs[0].via_waypoints.length; i++) {      wp.push({"location" : my.routes[0].legs[0].via_waypoints.lat() + "," + my.routes[0].legs[0].via_waypoints.lng() });  }  data.waypoints = wp;  ajaxRequest(OE4, "directions_changed",     ["count=" + my.routes[0].legs[0].steps.length ,     "directionsDisplay=" + JSON.stringify(data)     "directionsRoutes=" + JSON.stringify(directionsDisplay.getDirections(), null, "\t")     ]); });
 
 
If I reinstall the version 1.4.6 everything will return to work perfectly.
 
Where am I wrong?
 
Thank you

 

Link to comment
Share on other sites

 

Hi lema

I use unimgmap. Interestingly, The map is loaded and sometimes the map is not loaded
It does not know exactly why.
Where do I make a mistake?
please guide me ...
Thanks

 

 

Hello,

could you please upload a sample application demonstrating the problem ?

 

 

Also, check at this:

http://forums.unigui.com/index.php?/topic/2363-google-maps-for-unigui/page-20&do=findComment&comment=46531

Link to comment
Share on other sites

 

Hi Lema,
 
after installing version 1.4.8 (with unigui Pro uni-1.0.0.1403), the route function displays an error and does not work.
The error also comes with uniGMap Demo (I've compiled on my PC)
If I open the DIRECTIONS example and click on GO, the application shows a script error with the "Unexpected string" message and the following text:
 
....
 
If I reinstall the version 1.4.6 everything will return to work perfectly.

 
Where am I wrong?
 
Thank you

 

 

Hello,

please double check that the Google Maps Directions API in your Google API Key is enabled.

Link to comment
Share on other sites

  • 2 weeks later...

 

Hello,

could you please upload a sample application demonstrating the problem ?

 

 

Also, check at this:

http://forums.unigui.com/index.php?/topic/2363-google-maps-for-unigui/page-20&do=findComment&comment=46531

 

 

Hello, the sample seems to work fine on my end with:

Delphi Seattle

UniGUI 1.0.0.1413 Complete

 

 

Do you have problem with the specific project?

Link to comment
Share on other sites

  • 1 month later...

**EDIT** Sorted myself - skip to end for answer.

 

Hi Lema,

 

Firstly thanks for the component, post card will be in the post soon!

 

Just one issue - I use SSL (https) from a a IIS ISAPI dll - the only way I can get it to work is to allow the site to 'load scripts from unauthorized sources'. Doing this makes my 'secure' site 'unsecure'

 

The only method I call is UniGMap1.Geocoding('valid address', true); 

 

I guess the component loads the google library using http, not https - is their anything I can do about this? tell the component to load it from a https source?

 

If i do not allow 'load scripts from unauthorized sources' I get 'google is not defined' - as the library is obviously not loaded.

 

Can I override the path for http://maps.googleapis.com/maps/api/js?key=[API_KEY]&callback=initMap

to

https://maps.googleapis.com/maps/api/js?key=[API_KEY]&callback=initMap somehow?

 

 

**EDIT**  I thought Adding https://maps.googleapis.com/maps/api/js?key=[API_KEY]&callback=initMap  to CustomFiles in ServerModule, might help, but it does not - I still get the complaint of 'This page is trying to load scripts from unauthenticated sources' - So it must be something to do with where the script is being loaded from. (i think) 

 

This is what I get if I load scripts from 'unauthorized sources' https://www.dropbox.com/s/0tw4mliqdw6f9y7/2018-01-21_23-17-55.png If I allow the script to run everything works as expected.

 

 

Any ideas?

 

**EDIT** I have just found the maps api URL in GMaps.pas constructor, doh!!!

 

Left here in case anyone else has the issue and doesn't check in the most obvious place first!!

Link to comment
Share on other sites

Hello, did anyone get to use the mapdblclick and mapclick events on the mobile at the same time? always triggers only the mapclick event.

 

Google Translate.

Hello, did anyone get to use the mapdblclick and mapclick events on the mobile at the same time? always triggers only the mapclick event

Link to comment
Share on other sites

When I use HTTPS it gives the error below when using the component! If only used as normal HTTP works! What could it be?

 

Source

 

    UniGMap1.RemoveAllRoutes;
 
    with DirectionsRequest do
    begin
      origin := 'rua amadeu perin, 200 colombo, pr';
      destination := 'curitiba, pr';
      travelMode := tmDRIVING;
      draggable := True;
      waypoints := '';
    end;
 
    UniGMap1.Route(DirectionsRequest);

 

Error:

 

ajaxRequest(O6D,"resize",["w="+O6D.getWidth(),"h="+O6D.getHeight()]);if(Ext.Msg.isVisible())Ext.Msg.toFront();if (typeof directionsDisplay != "undefined") {  directionsDisplay.setMap(null);};var rendererOptions = {draggable: true};directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);var directionsService = new google.maps.DirectionsService();  var request = {   origin                   : "rua amadeu perin, 56 colombo, pr",   destination              : "curitiba, pr",   travelMode               : google.maps.DirectionsTravelMode.DRIVING,   unitSystem               : google.maps.UnitSystem.METRIC,   waypoints                : [],   avoidHighways            : false,   provideRouteAlternatives : false,   avoidTolls               : false};  directionsService.route(request, function(response, status){  if ( status == google.maps.DirectionsStatus.OK ) {    directionsDisplay.setDirections(response);    directionsDisplay.setMap(gm_O31);  } else {alert(status);}});  google.maps.event.addListener(directionsDisplay, "directions_changed", function() {  var steps = [];  var wp    = [];  var my    = directionsDisplay.getDirections();   var data  = {};  data.copyrights     = my.routes[0].copyrights;  data.distancetext   = my.routes[0].legs[0].distance.text;  data.distancevalue  = my.routes[0].legs[0].distance.value;  data.durationtext   = my.routes[0].legs[0].duration.text;  data.durationvalue  = my.routes[0].legs[0].duration.value;  data.startaddress   = my.routes[0].legs[0].start_address;  data.endaddress     = my.routes[0].legs[0].end_address;  data.startlocation  = {"lat": my.routes[0].legs[0].start_location.lat(),"lng":my.routes[0].legs[0].start_location.lng()};  data.endlocation    = {"lat": my.routes[0].legs[0].end_location.lat(),"lng":my.routes[0].legs[0].end_location.lng()};  for ( var i=0; i < my.routes[0].legs[0].steps.length; i++) {    steps.push({      "enc_lat_lngs"   : my.routes[0].legs[0].steps.encoded_lat_lngs,      "instructions"   : my.routes[0].legs[0].steps.instructions,      "distancetext"   : my.routes[0].legs[0].steps.distance.text,      "distancevalue"  : my.routes[0].legs[0].steps.distance.value,      "durationtext"   : my.routes[0].legs[0].steps.duration.text,      "durationvalue"  : my.routes[0].legs[0].steps.duration.value,      "startlocation"  : {"lat": my.routes[0].legs[0].steps.start_location.lat(),"lng": my.routes[0].legs[0].steps.start_location.lng()},      "endlocation"    : {"lat": my.routes[0].legs[0].steps.end_location.lat(),"lng": my.routes[0].legs[0].steps.end_location.lng()}    });  }  data.steps = steps;  for ( var i=0; i < my.routes[0].legs[0].via_waypoints.length; i++) {      wp.push({"location" : my.routes[0].legs[0].via_waypoints.lat() + "," + my.routes[0].legs[0].via_waypoints.lng() });  }  data.waypoints = wp;  ajaxRequest(O31, "directions_changed",     ["count=" + my.routes[0].legs[0].steps.length ,     "directionsDisplay=" + JSON.stringify(data)     ]); });if (navigator.geolocation) {   navigator.geolocation.getCurrentPosition( function(position) {     ajaxRequest(MainForm.btLocation, "CurrentPosition" ,      ["lat=" + position.coords.latitude,        "lng=" + position.coords.longitude,        "acc=" + position.coords.accuracy,        "alt=" + position.coords.altitude,        "altacc=" + position.coords.altitudeAccuracy,        "head=" + position.coords.heading,        "ts=" + position.coords.timestamp       ]);    })};

Link to comment
Share on other sites

  • 2 weeks later...

Hello lema:

 

There is a bug with clusters and markersEx due to recent google maps API changes.

Now, the clusters won´t appear and a Ajax error pops: "Cannot read property 'removeChild' of null"

You can open your own online demo and click the button: "Marker Clusterer", and then, click the "Add markersEx" and the error will show up.

 

Greetings

  • Upvote 2
Link to comment
Share on other sites

hello , i use  uniGMap component V 1.4.8 it is greate job thanks ... but when i wan create marker  i get exeption Acces violation at adresse 040BE4E ...

this is my code :

 

 

procedure TF_Gmap.UniButton1Click(Sender: TObject);

var lng , lat : real;
begin
DTM.Vehicule.First;
lat := 0;
lng := 0;
while Not DTM.Vehicule.Eof do
  begin
   with MarkersEx[DTM.VehiculeRECORDID.Value] do
                begin
                  id := DTM.VehiculeRECORDID.Value;
                  Latitude := 36.733924 - lat;
                  Longitude := 3.274754 + lng;
                  labelAnchor.X := 50;
                  labelAnchor.Y := 50;
                  labelClass := 'myLabel';
                  labelContent := DTM.VehiculeALIAS.Text;
                  labelAnchor.X := 50;
                  labelAnchor.Y := 50;
                  clickable := true; /// a enlevé
                  draggable := True; /// a enlevé
                  labelInBackground := False;
                  labelVisible := True;
                  labelStyle := '{ opacity: 0.50 , color: "green" , width: "150px" }';
                  icon := '/files/images/45.png';
                end;
                UniGMap1.AddMarkerEx(MarkersEx[DTM.VehiculeRECORDID.Value], True);
                lat := 0.36271281838859;
                lng := 0.003004074096709;
    DTM.Vehicule.Next;
  end;
end;
 
 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...