Hi Davie,

Many thanks for the code, very clever!

I'm going to try and see whether I can make the changes without changing my
php scripts, but what you posted is certainly very interesting.

Kind regards

Chris

On 8 December 2011 11:51, davie <[email protected]> wrote:

> Hi
>
> The php file which generates the XML from MySQL uses the function
> mysql_num_rows()
> This is used to modify the XML depending on whiter the search provides
> results or not
> Here is my code (obviously your data fields are different from mine)
> //////
> header("Content-type: text/xml");
> if (mysql_num_rows($result)==0) {
>        $node = $dom->createElement("marker");
>        $newnode = $parnode->appendChild($node);
>        $newnode->setAttribute("name", "No Records Found");
>        $newnode->setAttribute("address","Centered on Location");
>        $newnode->setAttribute("lat", $center_lat);
>        $newnode->setAttribute("lng", $center_lng);
>        $newnode->setAttribute("distance", 0);
>                                }
>
>    else {
>        // 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("lat", $row['lat']);
>                $newnode->setAttribute("lng", $row['lng']);
>                $newnode->setAttribute("distance", $row['distance']);
>        }
>
> }
>
>
> echo $dom->saveXML();
> echo $xmlfile;
>
> //////..
> This will always create 1 marker even if no records are found.
> In the calling file  the first markerNode name is checked and if it is
> "No Records Found"  the default marker is used otherwise the other
> marker is used.
> ie
>  var name = markerNodes[0].getAttribute("name");
>           if(name=="No Records Found") {
>                mode =0;
>           }
>           else{
>           mode =1;
>           }
>
>
> Regards Davie
>
>
> On Dec 7, 4:43 pm, IR HM <[email protected]> wrote:
> > Hi Davie, many thanks for taking the time to reply to my post. This looks
> > like it will do the trick.
> >
> > However I've implemented it and updated my page, but unfortunately I'm
> > still getting the default google icon.
> >
> > Any ideas please?
> >
> > Kind regards
> >
> > Chris
> >
> > On 7 December 2011 16:25, davie <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi
> > > See my maphttp://daviestrachan.zxq.net/maps/stationmap.php
>  > > If you type in Paris with a radius of 25 miles the marker locates in
> > > Paris where there are no records with ! marker
> > > if you type in London any radius there are records and you get railway
> > > marker
> > > Is this somthing like you want?
> > > Regards Davie
> >
> > > On Dec 7, 3:22 pm, IR HM <[email protected]> wrote:
> > > > I wonder whether someone may be able to help me please.
> >
> > > > I'm trying to use custom icons on
> > > > this<http://www.mapmyfinds.co.uk/development/mylocationstest.html>
> > >  > page
> > > > but I've come up against a problem. The page uses two php files to
> > > retrieve
> > > > it's data and it's the custom icons from the second file that I can't
> > > seem
> > > > to show on my map. I know the formatting on the page at the moment
> isn't
> > > > great, but this is just a test file. To see the problem I'm having,
> > > select
> > > > the blue link called 'Test Location 2', leave the drop down menu
> value at
> > > > '5' and click 'Search Location'.
> >
> > > > I can get the custom icons working for these:
> >
> > > > "Finds made": {
> > > > icon: 'location-marker2.png',
> > > > shadow: 'location-marker2-shadow.png'},
> >
> > > > "No finds made": {
> > > >  icon: 'location-marker1.png',
> > > > shadow: 'location-marker1-shadow.png'
> >
> > > > },
> >
> > > > Which take their data from the first php file, but the set from the
> > > second
> > > > file (shown below), don't appear on the map, I just get the default
> > > google
> > > > marker.
> >
> > > > "Battlefield": {
> > > > icon: 'battle-marker.png',
> > > > shadow: 'battle-marker-shadow.png'
> > > >  },
> > > > "Monument": {
> > > > icon: 'artifact-marker.png',
> > > > shadow: 'artifact-marker-.png'
> >
> > > > }
> > > > };
> >
> > > > The markers are created within this function:
> >
> > > > function createMarker2(latlng, sitedescription, sitetype) {
> >
> > > > I've tried all manner of different positions within this code to set
> the
> > > > custom icon variable, but I just can't get it to work. I've even
> tried to
> > > > create a var customIcons2, but this doesn't work either.
> >
> > > > I just wondered whether someone could have a look at this please and
> let
> > > me
> > > > know what I'm doing wrong.
> >
> > > > Many thanks kind regards
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Google Maps JavaScript API v3" group.
> > > To post to this group, send email to
> > > [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > For more options, visit this group at
> > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to