Jump to content

PHP, Google Maps and KML


ankhmor

Recommended Posts

I'm having trouble loading this kind of KML with PHP

http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#RetrievingFeatures

example

<atom:entry xmlns='http://www.opengis.net/kml/2.2'
    xmlns:atom='http://www.w3.org/2005/Atom'
    xmlns:batch='http://schemas.google.com/gdata/batch'
    xmlns:gd='http://schemas.google.com/g/2005'>
  <atom:id>
  http://maps.google.com/maps/feeds/features/userID/mapID/full/featureID</atom:id>
  <atom:published>2008-08-14T17:46:06.462Z</atom:published>
  <atom:updated>2008-08-14T18:12:31.589Z</atom:updated>
  <atom:category scheme='http://schemas.google.com/g/2005#kind' 
.....

 

it seems like the column in atom:entry, etc is causing this.

 

$response = simplexml_load_string($response);

print_r($response);

 

the above just gives an empty SimpleXMLElement Object()

 

Any ideas

Link to comment
https://forums.phpfreaks.com/topic/217392-php-google-maps-and-kml/
Share on other sites

Using print_r or var_dump on a SimpleXML object won't be very helpful. If you want to see the XML, for example to make sure it was loaded, use $response->asXML().  For what it's worth, if the XML string could not be parsed for any reason then simplexml_load_string would return FALSE and one or more E_WARNINGS would have been printed with the specific problem.

Ok

So I've researched a bit and now I understand namespaces, but I still cannot access the

<coordinate></coordinate>

 

can someone please write an simplexml path of how to get the coordinates?

http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#RetrievingFeatures

<atom:content type='application/vnd.google-earth.kml+xml'>
    <Placemark xmlns="http://www.opengis.net/kml/2.2">
      <name>East River Line</name>
      <description>
        <![CDATA[A streetcar proposal for New York's Brooklyn and Queens
        waterfront]]>
      </description>
      <Style>
        <LineStyle>
          <color>73FF0000</color>
          <width>5</width>
        </LineStyle>
      </Style>
      <LineString>
        <tessellate>1</tessellate>
        <coordinates>-73.872446,40.774481,0.0
        ...
        -74.005537,40.671329,0.0</coordinates>
      </LineString>
    </Placemark>
  </atom:content>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.