Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find and read metadata using jQuery (schema.org microformat)?

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?

like image 204
Diodeus - James MacFarlane Avatar asked Nov 01 '11 16:11

Diodeus - James MacFarlane


2 Answers

Have you tried this?

jQuery(function($){
  var latitude = $('.geo meta[itemprop="latitude"]').attr("content");
  var longitude = $('.geo meta[itemprop="longitude"]').attr("content");
});
like image 193
rmorero Avatar answered Oct 21 '22 04:10

rmorero


You can get at the data like so:

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

like image 21
Alex Avatar answered Oct 21 '22 06:10

Alex