V3 Driving Directions and Marker html on the store locator

221 views
Skip to first unread message

n6ach

unread,
Sep 5, 2011, 8:51:41 PM9/5/11
to google-map...@googlegroups.com
I have been searching the forum for the past week after converting a website to v3 with no joy.

I would like to be able to have someone get driving directions when they click on the marker. Also to be able to select the website link if available. The website is at http://findingstorage.com/ and I use phpsqlsearch_genxml.php 


The text from phpsqlsearch:
// Iterate through the rows, adding XML nodes for each
  while ($row = @mysql_fetch_assoc($result)){
  $node = $dom->createElement("marker");
  $newnode = $parnode->appendChild($node);
  $newnode->setAttribute("name", $row['name']);
  $newnode->setAttribute("address", $row['address']);
  $newnode->setAttribute("city", $row['city']);
  $newnode->setAttribute("state", $row['state']);
  $newnode->setAttribute("phone", $row['phone']);
  $newnode->setAttribute("website", $row['website']);
  $newnode->setAttribute("lat", $row['lat']);
  $newnode->setAttribute("lng", $row['lng']);
  $newnode->setAttribute("distance", $row['distance']);

Ralph

unread,
Sep 5, 2011, 9:23:08 PM9/5/11
to google-map...@googlegroups.com
On 06/09/2011 03:51, n6ach wrote:
>
> >>I would like to be able to have someone get driving directions when
> they click on the marker. Also to be able to select the website link
> >>if available. The website is at http://findingstorage.com/ and I
> use phpsqlsearch_genxml.php

Try this link it might help:

http://www.easypagez.com/maps/directions.html
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/7l22EQhCziIJ.
> To post to this group, send email to
> google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.

n6ach

unread,
Sep 10, 2011, 3:41:02 PM9/10/11
to google-map...@googlegroups.com
Thanks I am trying to make it go now :)

Any ideas on how to get it to pass a href link in side the marker? If you look at my version and search 95203 the first listing has a weblink, I would like to have that link clickable. 

Thanks again

MymsMan

unread,
Sep 10, 2011, 3:54:32 PM9/10/11
to google-map...@googlegroups.com
Try http://stackoverflow.com/questions/37684/how-to-replace-plain-urls-with-links/3890175#3890175

It is quite difficult to reliably parse links in text but the routine in the attached link seems to work well with most link formats.

n6ach

unread,
Sep 10, 2011, 4:12:24 PM9/10/11
to google-map...@googlegroups.com
Thank you very much, I have been spending quite a bit of time on that site since I started the project and never came across that page. That will be a huge help.

On the directions sample page, it looks like it is for v3 however the marker text, they use single quotes like v2.  Can you still use single quotes.

function createMarker(point,map,infoWindow,html,name)
 {
var marker = new google.maps.Marker({position:point,map:map,title:name});
var i = gmarkers.length;
to_htmls[i] = html + '<br>Directions: <b>To here<\/b> - <a href="javascript:fromhere(' + i + ')">From here<\/a>' +
'<br>Start address:<form action="javascript:getDirections()">' +
'<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
'<INPUT value="Get Directions" TYPE="SUBMIT"><br>' +
'Walk <input type="checkbox" name="walk" id="walk" /> &nbsp; Avoid Highways <input type="checkbox" name="highways" id="highways" />' +
'<input type="hidden" id="daddr" value="'+ point.lat() + ',' + point.lng() +
'"/>';
from_htmls[i] = html + '<br>Directions: <a href="javascript:tohere(' + i + ')">To here<\/a> - <b>From here<\/b>' +
'<br>End address:<form action="javascript:getDirections()">' +
'<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
'<INPUT value="Get Directions" TYPE="SUBMIT"><br>' +
'Walk <input type="checkbox" name="walk" id="walk" /> &nbsp; Avoid Highways <input type="checkbox" name="highways" id="highways" />' +
'<input type="hidden" id="saddr" value="'+ point.lat() + ',' + point.lng() +
'"/>';
html = html + '<br>Directions: <a href="javascript:tohere('+i+')">To here<\/a> - <a href="javascript:fromhere('+i+')">From here<\/a>';  



I use the double quotes v3 calls for:

function createMarker(latlng, name, address, city, state, phone, website) {
      var html = "<b>" + name + "</b> <br/>" + address + "<br/>" + city + ", " + state + "<br/>" + phone + "<br/>" + website;

my programming trial page is at http://findingstorage.com/directions.php
Reply all
Reply to author
Forward
0 new messages