10

I'm building a Google Maps application and I'd like to read out the metadata, as specified by schema.org, from my HTML to plot my map markers.

For example:

<li itemscope="itemscope" itemtype="http://schema.org/LocalBusiness">
...some html... 
  <div class="geo" itemprop="geo" itemscope="itemscope" itemtype="http://schema.org/GeoCoordinates">
    <meta itemprop="latitude" content="43.681505" />
    <meta itemprop="longitude" content="-79.294455" />
  </div>
</li>

Is there an easy way to query out the latitude and longitude values without having loop through everything?

Diodeus - James MacFarlane
  • 107,156
  • 31
  • 147
  • 171

2 Answers2

22

Have you tried this?

jQuery(function($){
  var latitude = $('.geo meta[itemprop="latitude"]').attr("content");
  var longitude = $('.geo meta[itemprop="longitude"]').attr("content");
});
rmorero
  • 596
  • 4
  • 10
4

You can get at the data like so:

$('meta[itemprop="latitude"]').attr('content')

Alex
  • 8,574
  • 2
  • 25
  • 42