FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour 驴C贸mo puedo marcar varios puntos con Google Maps?
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Tue Oct 13, 2020 11:12 PM
Buenas noches, por favor:

驴C贸mo puedo marcar varios puntos con Google Maps?
cree una matriz con los datos (nombre, direcci贸n, c贸digo postal, ciudad, estado, etc.)
Y enviar a Google para posicionar en el mapa

Tipo:



Gracias,

Regards, saludos.
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Wed Oct 14, 2020 10:13 PM
Karinha:
Si te refieres a mostrar Markers, yo lo he hecho en php
Te dejo un script tal vez te sirva
Code (fw): Select all Collapse
<script>
var map1, heatmap;


function initMap1() {
  map1 = new google.maps.Map(document.getElementById('map1'), {
    zoom: 13,
    center: {lat: -34.6629, -59.4211},
    styles: [
            {
              featureType: 'poi',
              elementType: 'labels',
              stylers: [{ visibility: "off" }]
            }
            ]

  });
  <?php $coor = explode(",", $res->ubicacion);?>
  var marker = new google.maps.Marker({
           position: {lat:-34.648238, lng:-59.423975},
           icon: '/img/mimarcador.png', // Aca podes definir un marcador personalizado
           map: map1,
           title: 'Mi Taller'
           });
           var contentString = '<div id="content">'+
            '<div id="siteNotice">'+
            '</div>'+
            '<h4 id="firstHeading" class="firstHeading">Mi Taller</h4>'+
            '<div id="bodyContent">'+
            '<p>Rubro: Taller<b></p>'+
            '<p>Para comprar: <a href="verproductos/taller">'+
            'Ir al comercio</a></p>'+
            '</div>'+
            '</div>';

            var infowindow = new google.maps.InfoWindow({
              content: contentString,
              maxWidth: 230
            });
           marker.setMap(map1);
           google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){ 
                return function() {
                    infowindow.setContent(content);
                    infowindow.open(map,marker);
                };
            })(marker,contentString,infowindow));  
  var marker = new google.maps.Marker({
           position: {lat:-34.662994, lng:-59.421197},
           icon: '/img/mimarcador1.png', // Aca podes definir otro marcador personalizado
           map: map1,
           title: 'Mi Laboratorio'
           });
           var contentString = '<div id="content">'+
            '<div id="siteNotice">'+
            '</div>'+
            '<h4 id="firstHeading" class="firstHeading">Mi Laboratorio</h4>'+
            '<div id="bodyContent">'+
            '<p>Rubro: Laboratorio<b></p>'+
            '<p>Para comprar: <a href="verproductos/laboratorio">'+
            'Ir al comercio</a></p>'+
            '</div>'+
            '</div>';

            var infowindow = new google.maps.InfoWindow({
              content: contentString,
              maxWidth: 230
            });
           marker.setMap(map1);
           google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){ 
                return function() {
                    infowindow.setContent(content);
                    infowindow.open(map,marker);
                };
            })(marker,contentString,infowindow));         
}
</script>
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Sat Oct 17, 2020 11:24 AM
Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Sat Feb 12, 2022 03:09 PM
karinha wrote:Buenas noches, por favor:

驴C贸mo puedo marcar varios puntos con Google Maps?
cree una matriz con los datos (nombre, direcci贸n, c贸digo postal, ciudad, estado, etc.)
Y enviar a Google para posicionar en el mapa

Tipo:



Gracias,

Regards, saludos.


Hola, Jo茫o. Estoy buscando, como t煤 quer铆as, c贸mo a帽adir marcadores a googel maps como t煤. Es decir, a帽adir marcadores de nombre, direcci贸n, c贸digo postal y, adem谩s, actividad profesional. Lo has consegurido hacer?

En mi caso ser铆a insertar marcadores de 2.000 empresas, todas ellas ubicadas en la misma regi贸n. Por ejemplo:
cRegion:="Comunidad Valenciana"
cProvincia:="Alicante"
cLocalidad:= "Benidorm"
cdomicilio:= "Avenida de Madrid, s/n"
cCP:="03501"
Actividad:= "Producci贸n agr铆cola"

No s茅 c贸mo insertar todos los registros en un mapa. He visto muchos ejemplos, pero todos ellos toman como referencia la latitud y longitud (cosa l贸gica,por otra parte), 驴pero sin las coordenadas se puede hacer?

Saludos
FWH 20.12 BCC7
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Sun Feb 13, 2022 04:43 PM
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Sun Feb 13, 2022 06:40 PM

Gracias, Antonio, voy a probar tus sugerencias.

Saludos

FWH 20.12 BCC7
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Tue Feb 15, 2022 06:17 PM
Hola a todos

Siguiendo los ejemplos de Antonio, he construido un mapa, pero me gustar铆a c贸mo incluyo los marcadores desde la dbf y asignarles un marcador diferente seg煤n sea la actividad profesional.

El c贸digo con el que he construido el mapa es el siguiente:

Code (fw): Select all Collapse
<!DOCTYPE html>
<html lang="es">
<head>
</head>
<body>
聽 聽 
<div id="map_canvas" style="width:750px; height:450px; border: 2px solid #3872ac;"></div>
<script
type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=[REDACTED:GOOGLE_API_KEY]&libraries=places">
</script>



<script type="text/javascript">
聽 聽 var locations = [
聽 聽 ['Location 1 Name', 'Val猫ncia, Comunidad Valencia, Espa帽a', 'Location 1 URL'],
聽 聽 ['Location 2 Name', 'Benidorm, Comunidad Valenciana, Espa帽a', 'Location 2 URL'],
聽 聽 ['Location 3 Name', 'Vinar贸s, Comunidad Valenciana, Espa帽a', 'Location 3 URL']
];

var geocoder;
var map;
var bounds = new google.maps.LatLngBounds();

function initialize() {
聽 聽 map = new google.maps.Map(
聽 聽 document.getElementById("map_canvas"), {
聽 聽 聽 聽 center: new google.maps.LatLng( 39.13354, -0.491389),
聽 聽 聽 聽 zoom: 13,
聽 聽 聽 聽 mapTypeId: google.maps.MapTypeId.ROADMAP
聽 聽 });
聽 聽 geocoder = new google.maps.Geocoder();

聽 聽 for (i = 0; i < locations.length; i++) {
聽 聽 聽 聽 geocodeAddress(locations, i);
聽 聽 }
}
google.maps.event.addDomListener(window, "load", initialize);

function geocodeAddress(locations, i) {
聽 聽 var title = locations[i][0];
聽 聽 var address = locations[i][1];
聽 聽 var url = locations[i][2];
聽 聽 geocoder.geocode({
聽 聽 聽 聽 'address': locations[i][1]
聽 聽 },

聽 聽 function (results, status) {
聽 聽 聽 聽 if (status == google.maps.GeocoderStatus.OK) {
聽 聽 聽 聽 聽 聽 var marker = new google.maps.Marker({
聽 聽 聽 聽 聽 聽 聽 聽 icon: 'http://maps.google.com/mapfiles/ms/icons/blue.png',
聽 聽 聽 聽 聽 聽 聽 聽 map: map,
聽 聽 聽 聽 聽 聽 聽 聽 position: results[0].geometry.location,
聽 聽 聽 聽 聽 聽 聽 聽 title: title,
聽 聽 聽 聽 聽 聽 聽 聽 animation: google.maps.Animation.DROP,
聽 聽 聽 聽 聽 聽 聽 聽 address: address,
聽 聽 聽 聽 聽 聽 聽 聽 url: url
聽 聽 聽 聽 聽 聽 })
聽 聽 聽 聽 聽 聽 infoWindow(marker, map, title, address, url);
聽 聽 聽 聽 聽 聽 bounds.extend(marker.getPosition());
聽 聽 聽 聽 聽 聽 map.fitBounds(bounds);
聽 聽 聽 聽 } else {
聽 聽 聽 聽 聽 聽 alert("geocode of " + address + " failed:" + status);
聽 聽 聽 聽 }
聽 聽 });
}

function infoWindow(marker, map, title, address, url) {
聽 聽 google.maps.event.addListener(marker, 'click', function () {
聽 聽 聽 聽 var html = "<div><h3>" + title + "</h3><p>" + address + "<br></div><a href='" + url + "'>View location</a></p></div>";
聽 聽 聽 聽 iw = new google.maps.InfoWindow({
聽 聽 聽 聽 聽 聽 content: html,
聽 聽 聽 聽 聽 聽 maxWidth: 350
聽 聽 聽 聽 });
聽 聽 聽 聽 iw.open(map, marker);
聽 聽 });
}

function createMarker(results) {
聽 聽 var marker = new google.maps.Marker({
聽 聽 聽 聽 icon: 'http://maps.google.com/mapfiles/ms/icons/blue.png',
聽 聽 聽 聽 map: map,
聽 聽 聽 聽 position: results[0].geometry.location,
聽 聽 聽 聽 title: title,
聽 聽 聽 聽 animation: google.maps.Animation.DROP,
聽 聽 聽 聽 address: address,
聽 聽 聽 聽 url: url
聽 聽 })
聽 聽 bounds.extend(marker.getPosition());
聽 聽 map.fitBounds(bounds);
聽 聽 infoWindow(marker, map, title, address, url);
聽 聽 return marker;
}
</script>
</body>聽
</html>


Gracias
FWH 20.12 BCC7
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Wed Feb 16, 2022 08:58 AM
Ram贸n,

En este ejemplo puedes visualizar tu fichero HTML desde tu aplicaci贸n desktop.

Como el fichero HTML se carga desde un fichero en tu PC, solo tienes que tener varios creados 贸 generarlo dinamicamente
usando DBFs, colores, seg煤n necesites. Para construirlo haz: FWH\samples\buildh32.bat ramon

Si necesitas construirlo usando Borland, aqui tienes las instrucciones de como hacerlo:
viewtopic.php?p=246459&sid=65fe9ba9c00a26a586f10b5636b63fc3#p246459

ramon.prg
Code (fw): Select all Collapse
#include "FiveWin.ch"

#define SW_HIDE 聽 聽 聽 聽 聽0
#define SW_SHOW 聽 聽 聽 聽 聽5
#define GWL_STYLE 聽 聽 聽-16

static hDLL, s_nCalls, s_cJsonResult

function Main()

聽 聽local oWnd

聽 聽hDLL = LoadLibrary( "webview.dll" )

聽 聽DEFINE WINDOW oWnd

聽 聽ACTIVATE WINDOW oWnd ;
聽 聽 聽 ON INIT CreateWebView( oWnd )

聽 聽FreeLibrary( hDLL )

return nil

function CreateWebView( oWnd )

聽 聽local hWebView := WebView_Create()
聽 聽local hWnd 聽 聽 := WebView_Get_Window( hWebView )
聽 聽local nStyle

聽 聽ShowWindow( hWnd, SW_HIDE )
聽 聽oWnd:SetSize( 1000, 600 ) 
聽 聽oWnd:Center()
聽 聽nStyle 聽 := GetWindowLong( hWnd, GWL_STYLE )
聽 聽nStyle 聽 -= WS_CAPTION
聽 聽nStyle 聽 -= WS_SYSMENU
聽 聽nStyle 聽 += WS_THICKFRAME
聽 聽SetWindowLong( hWnd, GWL_STYLE, nStyle )
聽 聽SetParent( hWnd, oWnd:hWnd )
聽 聽SetWindowPos( hWnd,, 10, 10, 770, 470, 0 )
聽 聽WebView_Navigate( hWebView, "file:///c:/soporte/Ramon/test.html" )
聽 聽WebView_Bind( hWebView, "SendToFWH", SendToFWHAddress(), hWebView )
聽 聽oWnd:Refresh()
聽 聽ShowWindow( hWnd, SW_SHOW )

return nil

function WebView_SaveValues( cCalls, cJsonResult )

聽 聽s_nCalls = Val( cCalls )
聽 聽s_cJsonResult = cJsonResult

聽 聽MsgInfo( hb_ValToExp( s_cJsonResult ), s_nCalls )

return nil 聽

DLL FUNCTION WEBVIEW_CREATE( nDebug AS LONG, hWndParent AS LONG ) AS LONG PASCAL FROM "webview_create" LIB hDLL
DLL FUNCTION WEBVIEW_RUN( hWebView AS LONG ) AS VOID PASCAL FROM "webview_run" LIB hDLL
DLL FUNCTION WEBVIEW_NAVIGATE( hWebView AS LONG, cUrl AS LPSTR ) AS VOID PASCAL FROM "webview_navigate" LIB hDLL
DLL FUNCTION WEBVIEW_DESTROY( hWebView AS LONG ) AS VOID PASCAL FROM "webview_destroy" LIB hDLL
DLL FUNCTION WEBVIEW_BIND( hWebView AS LONG, cName AS LPSTR, pFunc AS LONG, pVoid AS LONG ) AS VOID PASCAL FROM "webview_bind" LIB hDLL
DLL FUNCTION WEBVIEW_EVAL( hWebView AS LONG, cJavaScript AS LPSTR ) AS VOID PASCAL FROM "webview_eval" LIB hDLL
DLL FUNCTION WEBVIEW_GET_WINDOW( hWebView AS LONG ) AS LONG PASCAL FROM "webview_get_window" LIB hDLL
#define WEBVIEW_HINT_NONE 聽0 聽 // Width and height are default size
#define WEBVIEW_HINT_MIN 聽 1 聽 // Width and height are minimum bounds
#define WEBVIEW_HINT_MAX 聽 2 聽 // Width and height are maximum bounds
#define WEBVIEW_HINT_FIXED 3 聽 // Window size can not be changed by a user
DLL FUNCTION WEBVIEW_SET_SIZE( hWebView AS LONG, nWidth AS _INT, nHeight AS LONG, nHint AS LONG ) AS VOID PASCAL FROM "webview_set_size" LIB hDLL
DLL FUNCTION WEBVIEW_SET_TITLE( hWebView AS LONG, cTitle AS LPSTR ) AS VOID PASCAL FROM "webview_set_title" LIB hDLL

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <hbvm.h>

static void SendToFWH( const char * szNumRequests, const char * szJson, void * p )
{
聽 聽hb_vmPushSymbol( hb_dynsymGetSymbol( "WEBVIEW_SAVEVALUES" ) );
聽 聽hb_vmPushNil();
聽 聽hb_vmPushString( szNumRequests, strlen( szNumRequests ) );
聽 聽hb_vmPushString( szJson, strlen( szJson ) );
聽 聽hb_vmFunction( 2 );
}

HB_FUNC( SENDTOFWHADDRESS )
{
聽 聽hb_retnl( ( HB_LONG ) SendToFWH );
}

#pragma ENDDUMP


regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 152
Joined: Mon Feb 13, 2006 08:23 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Wed Feb 16, 2022 02:29 PM
Gracias, Antonio, por tu inter茅s, pero, perdona mi torpeza, 驴en qu茅 parte del c贸digo conecto con la dbf?
Ejemplo: empresas.dbf con campos Denominaci贸n, direcci贸n, localidad, cp

He estado siguiente el hilo del enlace, pero no he visto (o no me he dado cuenta) desde d贸nde se recuperan los datos de la dbf para luego mostrarlos en el mapa. Creo que debe ser en la funci贸n

Code (fw): Select all Collapse
[function geocodeAddress(locations, i) {
聽 聽 var title = locations[i][0];
聽 聽 var address = locations[i][1];
聽 聽 var url = locations[i][2];
聽 聽 geocoder.geocode({
聽 聽 聽 聽 'address': locations[i][1]
聽 聽 }/code]


聽pero desconozco c贸mo se usa javascript para mostrar datos desde una dbf. 

[code]script type="text/javascript">
聽 聽 var locations = [
聽 聽 ['Location 1 Name', 'Val猫ncia, Comunidad Valencia, Espa帽a', 'Location 1 URL'],
聽 聽 ['Location 2 Name', 'Benidorm, Comunidad Valenciana, Espa帽a', 'Location 2 URL'],
聽 聽 ['Location 3 Name', 'Vinar贸s, Comunidad Valenciana, Espa帽a', 'Location 3 URL']
];





Saludos
FWH 20.12 BCC7
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Wed Feb 16, 2022 03:20 PM

Ram贸n,

La estructura de tu HTML es asi:

comienzo del html

var locations = [
['Location 1 Name', 'Val猫ncia, Comunidad Valencia, Espa帽a', 'Location 1 URL'],
['Location 2 Name', 'Benidorm, Comunidad Valenciana, Espa帽a', 'Location 2 URL'],
['Location 3 Name', 'Vinar贸s, Comunidad Valenciana, Espa帽a', 'Location 3 URL']

];

resto del HTML

Lo que haces es construir una cadena:

cHTML = cComienzoDelHtml + Localizaciones() + cFinalDelHtml

y luego haces memoWrit( cHTML, "test.html" ) y ya has generado el HTML con los datos que necesitas y lo vuelves a cargar con:
WebView_Navigate( hWebView, "file:///c:/soporte/Ramon/test.html" )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: 驴C贸mo puedo marcar varios puntos con Google Maps?
Posted: Thu Feb 17, 2022 08:07 AM

Ram贸n,

Aqui tienes un nuevo ejemplo m谩s sencillo y simple de usar:

viewtopic.php?p=248148sid=fa448bcab753e81999209f1d62b1ad07#p248148

&

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion