Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add a Google map to an application
Message
From
15/09/2008 22:39:28
Victor Chigne
Inteliventas
Peru
 
General information
Forum:
Visual FoxPro
Category:
Third party products
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01345639
Message ID:
01347800
Views:
46
Hello John.

Great code. Six months ago I was involved in a project which dealt with maps. I used Mapwindow, a free mapping activex similar to Mapx to do the project. For that I had to encapsulate the OCX into a VB6 activex in order to VFP to read it.

Now, looking at Google maps my project could have been a lot more easier because the user shouldn't have to look for maps in SHP format. But when I tried the gmaps approach I couldn't interact with the map, I mean your code is great to show some points in the map, but how could you let the user pick a location in the map and return it to your VFP program to store in the clients table? How could I draw a polyline on the map and store it in my application? Have you faced this need and solve it? Please let me know.

TIA
>>Hi,
>>
>>I would like to add a Google map showing the location of a customer. Has someone done this?
>
>Sure, it's a piece of cake. Here's some sample code I use to create a google map, you'll need to register with them for a site key.
>
>
>Here's the results of the following:http://www.shelbynet.com/earlypolls.htm
>
>
>
>Lparameters lcfile,M.LAT,M.LONG
>* just pass the fullpath, latitude,longitude,caption 
>Set Safety Off
>If Parameters()<1
>	Messagebox('Pass file name',16,'Alert',4)
>	Return
>Endif
>*!*	m.latx=TRANSFORM(checkadds.lat)
>*!*	m.longx=TRANSFORM(checkadds.long)
>Loca
>*INDEX on long TAG long
>Count To lnrecs
>*SKIP INT(RECCOUNT()/2)
>Locate
>Scatter Memvar
>lcfile=''
>Set Textmerge On
>Set Text To (lcfile) Noshow
>* kiosk server google api key ABQIAAAAkgy8Ufju8MmwuwcRfunFIhTutbnR_kcC9XzHscZz6PIEe4fV8xRa6TJ3UXG_zql3xm99dCU_-8MkPw
>\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>\    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>\<html xmlns="http://www.w3.org/1999/xhtml">
>\  <head>
>LCDESCR=ALLTRIM(UPPER(Poll))
>\<img src = "http://maps.google.com/mapfiles/kml/pal4/icon49.png" style="display:none">
>\    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
>\<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
>\<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
>\<META HTTP-EQUIV="EXPIRES" 
>\CONTENT="Mon, 22 Jul 2002 11:12:01 GMT">
>\    <title>Memphis Police Department's Real Time Crime Center - Reported Crimes</title>
>\    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAkgy8Ufju8MmwuwcRfunFIhTutbnR_kcC9XzHscZz6PIEe4fV8xRa6TJ3UXG_zql3xm99dCU_-8MkPw"
>\      type="text/javascript"></script>
>\    <script type="text/javascript">
>\
>\    //<![CDATA[
>\    function load() {
>\      if (GBrowserIsCompatible()) {
>\        var map = new GMap2(document.getElementById("map"));
>\        map.addControl(new GLargeMapControl());
>\        map.addControl(new GMapTypeControl());
>\        map.setCenter(new GLatLng(35.135173,-90.000082), 10);
>* the lat and lon above were hardcoded, change those to the coordinates for your centerpoint
>\
>\        // Create a base icon for all of our markers that specifies the
>\        // shadow, icon dimensions, etc.
>\        var baseIcon = new GIcon();
>*http://www.google.com/intl/en_ALL/mapfiles/
>\      //  baseIcon.shadow = "https://kiosk.memphispolice.org/images/shadow50.png";
>\        baseIcon.iconSize = new GSize(20, 34);
>\        baseIcon.shadowSize = new GSize(37, 34);
>
>\        baseIcon.iconAnchor = new GPoint(9, 34);
>\        baseIcon.infoWindowAnchor = new GPoint(9, 2);
>\        baseIcon.infoShadowAnchor = new GPoint(18, 25);
>\
>\        // Creates a marker whose info window displays the letter corresponding
>\        // to the given index.
>
>\        function createMarker(point, index, lctext) {
>\          // Create a lettered icon for this point using our icon class
>\          var icon = new GIcon(baseIcon);
>\          var lcicon = "http://www.google.com/mapfiles/markerO.png"
>\          icon.image = lcicon;
>\          var marker = new GMarker(point, icon);
>\
>\          GEvent.addListener(marker, "click", function() {
>\            marker.openInfoWindowHtml("<b>" + lctext+ "</b>");
>\          });
>\          return marker;
>\        }
>\
>\        // Add markers to the map at locations
>\        var bounds = map.getBounds();
>\        var southWest = bounds.getSouthWest();
>\        var northEast = bounds.getNorthEast();
>\        var lngSpan = northEast.lng() - southWest.lng();
>\        var latSpan = northEast.lat() - southWest.lat();
>\        for (var i = 0; i < <<lnrecs+1>>; i++) {
>SCAN
>* I have a table with fields named lat,long,address,poll. scanning through the following puts the
>* points on the map
>\          var point = new GLatLng(<<lat>>,<<long>>);
>
>	LCINFO=['Poll: ]+Alltrim(poll)+'</BR> Address:'+Alltrim(address)+'</BR> '+[']
>
>\		   var lctext = <<ALLTRIM(LCINFO)>>;
>\          map.addOverlay(createMarker(point, i,lctext));
>Endscan
>\        }
>\      }
>\    }
>\
>\    //]]>
>\    </script>
>\  </head>
>\  <body onload="load()" onunload="GUnload()">
>\    <div id="map" style="width: 600px; height: 400px"></div>
>Loca
>\<p>
>\
>\
>\
>cnt=0
>\<<TRANSFORM(RECCOUNT())>> Polls</br>
>SCAN
>*display the fields of this table in an html table
>cnt=cnt+1
>IF cnt=1
>\<table style="FONT: 10pt Verdana; BORDER-COLLAPSE: collapse" cellSpacing="0" cellPadding="3" width="75%" bgColor="#eeeeee" border="1">
>\	<tr bgColor="darkblue">
>\		<th style="COLOR: white; FONT-FAMILY: Verdana,Helvetica">Number</th>
>\		<th style="COLOR: white; FONT-FAMILY: Verdana,Helvetica">Poll</th>
>\		<th style="COLOR: white; FONT-FAMILY: Verdana,Helvetica">Address</th>
>\	</tr>
>endif
>\	<tr style="BACKGROUND: #ccccff" vAlign="top"><td align="left"><<cnt>></td><td align="left"><<Poll>></td><td><<address>></td></tr>
>Endscan
>*!*	\</font></tr>
>\</table>
>\  </body>
>\</html>
>Locate
>Set Textmerge To
>Set Textmerge Off
>
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform