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
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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.