This topic is locked
[SOLVED]

 Google Maps API

3/12/2009 9:46:31 PM
PHPRunner General questions
vin7102 author

Hello All,
Has anyone ever tried using google maps API with a PHPRunner application?

W
wrjost 3/13/2009

Hi, Vince,

well, I have done some experimenting with it - here is the result (Step two is the PHPR part).
Greetings,

Wilfried
P.S.: Feel free to add your own test - it's still experimental... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=38983&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

J
johan2009 3/13/2009

Hi, Vince,

well, I have done some experimenting with it - here is the result (Step two is the PHPR part).
Greetings,

Wilfried
P.S.: Feel free to add your own test - it's still experimental... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=38985&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />



Hi Wilfried,
Thanks for showing this experiment. Could you explain a bit more how you accomplished this within PHPRunner?
Regards,

Johan

vin7102 author 3/13/2009

Hi, Vince,

well, I have done some experimenting with it - here is the result (Step two is the PHPR part).
Greetings,

Wilfried
P.S.: Feel free to add your own test - it's still experimental... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=38987&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />


wrjost,
Hi, and thanks for the reply. I saw on a google maps API link that you can put the geocoder right into the php code so all you need to do is supply the database with the name and address, then when the map page loads, it grabs the address and runs a geocode search and inserts the coordinates right into the db for all the addresses. then the markers are then set to the map. It sounds like the only problem is that the entire database is re-geocoded each time the page is loaded so if you have a large number of listings in the db it could take a while. That wouldn't be the case for us though as it looks like we shouldn't have thousands of addresses to decode. I will keep you updated on my findings!
Regards,

Vince

W
wrjost 3/13/2009

@Johan

I'll post what code I have tonight when I get back home from work. But one thing already: you have to apply for an API-key for your particular domain - please check this
@Vince

I didn't know that possibility existed. (Maybe Google API internal geocoding is a new feature, after all, I did my tests in February of last year.) But I wanted to have each team enter their own address so it was up to them to do the geocoding. - Keep me posted.
Greetings to all from Germany,

Wilfried

vin7102 author 3/13/2009

@Johan

I'll post what code I have tonight when I get back home from work. But one thing already: you have to apply for an API-key for your particular domain - please check this
@Vince

I didn't know that possibility existed. (Maybe Google API internal geocoding is a new feature, after all, I did my tests in February of last year.) But I wanted to have each team enter their own address so it was up to them to do the geocoding. - Keep me posted.
Greetings to all from Germany,

Wilfried


Will do Wilfried, I'll be working on it today

Take care out there in Germany!

vin7102 author 3/13/2009

Hey guys,

If your bored check this forum site out for a Phoogle mod... 759 posts (WOW) on a google maps mod that seems to be working out for a lot of peeps!

It looks like the sample sites are down and retired but there is some useful info in the site. Looks like it will be closing up soon!
Check this out Johan and Wil
____

___
Update

I found one even better with great options.. Here is a very talented guy!

Click Here

vin7102 author 3/17/2009

Update For anyone interested in using a google maps app with your PHPRunner app, Its rather pretty simple. I've been successful with adding it right to the bottom of a list page (just above the footer), and also just creating a new php page all together and linking the map to a button or a hyper link. Googles map location search is also pretty simple to implement.

Just letting you guys know that the possibility is there for a neatly integrated map app for your PHPRunner projects.

I can post some code help if anyone would like to try it!

E
e61 3/17/2009

Update For anyone interested in using a google maps app with your PHPRunner app, Its rather pretty simple. I've been successful with adding it right to the bottom of a list page (just above the footer), and also just creating a new php page all together and linking the map to a button or a hyper link. Googles map location search is also pretty simple to implement.

Just letting you guys know that the possibility is there for a neatly integrated map app for your PHPRunner projects.

I can post some code help if anyone would like to try it!



Yes pleace Vince.

Adding a map at the bottom of View page is what I'm after.

The map shall get its lat/lng from the current post in view...
(Maybe some beer coming your way...)

vin7102 author 3/17/2009



Yes pleace Vince.

Adding a map at the bottom of View page is what I'm after.

The map shall get its lat/lng from the current post in view...
(Maybe some beer coming your way...)


e61,

Hi, I'm working on pulling lats and lngs from the list view. Right now I have a map with default coord's to open, then an address search form that goes through the geocoder and plots the marker on the map and sets focus to that area, and then there are some extra zoom controls that work pretty nice.

Here is what I have so far, you will have to get a key and paste it into this code where I have noted. Important, you have to sign up for the key using the url of your site or some of the functions like the geocoder search will not work. This code is in two parts, One is the links and setup and the other is the place holder. I explained where I put them to work properly for me.
This first script will go into the Templates folder >>your_page_list.htm page and I put it just above the </head> tag.

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=YOUR KEY GOES HERE AND INCLUDE THE QUOTE AT THE END"></script>

<script src="http://gmaps-utility-library.googlecode.com/svn/trunk/dragzoom/release/src/dragzoom.js"; type="text/javascript"></script>
<script type="text/javascript">
var map = null;

var geocoder = null;
function initialize() {

if (GBrowserIsCompatible()) {

map = new GMap2(document.getElementById("map_canvas"));

map.setCenter(new GLatLng(41.274538, -81.330085), 13);
// add controls...

map.addControl(new GMapTypeControl());

map.addControl(new GScaleControl());

map.addControl(new GOverviewMapControl());

geocoder = new GClientGeocoder();

// add zoom control....

var boxStyleOpts = { opacity: .2, border: "2px solid yellow" };

var otherOpts = {

buttonHTML: "<img src='zoom-control-inactive.png' />",

buttonZoomingHTML: "<img src='zoom-control-active.png' />",

buttonStartingStyle: {width: '17px', height: '17px'},

overlayRemoveTime: 0 };

map.addControl(new DragZoomControl(boxStyleOpts, otherOpts, {}),

new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(27,7)));

// add large map control under the zoom control since the large map control has different sizes...

map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7,32)));
map.setCenter(new GLatLng(41.274538, -81.330085), 13); // This is the initial coordinates that load when the page starts up

}

}
function showAddress(address) {

if (geocoder) {

geocoder.getLatLng(

address,

function(point) {

if (!point) {

alert(address + " not found");

} else {

map.setCenter(point, 13);

var marker = new GMarker(point);

map.addOverlay(marker);

marker.openInfoWindowHtml(address);

}

}

);

}

}
</script>


And the next code will place the map on the phprunner list page above the footer. I put mine just above the footer / after the {END message_block} on that same page:

</div>

<body onload="initialize()" onunload="GUnload()" style="font-family: Arial;border: 0 none;">
<form action="#" onsubmit="showAddress(this.address.value); return false">

<p>

<input type="text" size="60" name="address" value="123 any street, Anytown, Ohio" /> //This is the default value for the search text box

<input type="submit" value="Show!" /> //This is the search button title

</p>

<center><div id="map_canvas" style= " border-width: ; height: 300px"></div></center> // These are the map size attributes, I have it set to full width and 300px tall.. You can change it to whatever you like

</form>
</body>


I've been using filezilla as an ftp client so I dont have to upload the entire project each time I make a change but any ftp client will work. A good code editor also helps!

I'll give you an update once I get the map markers linked to mysql..

Have Fun

Vince

E
e61 3/17/2009

This is great Vince, almost there... ;-)

E
e61 3/22/2009

This is great Vince, almost there... ;-)


@vince:
Its easy to pull lat/lng from the view page.

Here's how I did it:



function initialize() {

if (GBrowserIsCompatible()) {

var map = new GMap2(document.getElementById("map_canvas"));

var Lat = {$lat_N_value};

var Lng = {$lon_E_value};

map.setCenter(new GLatLng(Lat, Lng), 15);

var point = (new GLatLng(Lat, Lng));

map.addOverlay(new GMarker(point));

map.addControl(new GSmallMapControl());

}

}
vin7102 author 3/23/2009

E61,
Got your reply.
Sorry, Ive been away for a while but I'll be getting back to it here in a couple days. Did you figure out a way to integrate the actual geocoding into our phprunner.
Hmm, I'm wondering what would be the best way to acquire the coordinates to store... Maybe first find the location and plot a marker on the map and then store the coords into the db after that location was coded and plotted?? Ideally though, it would be just awesome to enter the map address or location search criteria into a phprunner "Add" form then use a "before record updated" event to geocode the location with coords and update the db with the address and coords all at once...
Let me know if you have any other ideas. This could turn out really great!

Thanks,

Vince

T
tinem 4/1/2009

I'm also very interested in this subject and have made my info to your testmap but can't see where the map is to check if my marker?

W
wrjost 4/1/2009

I'm also very interested in this subject and have made my info to your testmap but can't see where the map is to check if my marker?


Hi, Tine,

go to http://www.euro-flyball.org/maps/map_display.htm and just change the scale of the map by clicking on the minus-key in the upper left hand corner, until Norway and Denmark appear... ;-)))
Greetings,

Wilfried