Update: it will place markers if fed two of the same coordinate, but not tweet.geocoordinates[1],tweet.geo.coordinates[0]. so tweet.geo.coordinates[0],tweet.geo.coordinates[0] places the marker somewhere in the middle of eurasia tweet.geo.coordinates[1],tweet.geo.coordinates[1] goes off the map below antarctica below the americas tweet.geo.coordinates[0],tweet.geo.coordinates[1] goes off the map below Antarctica below africa...
no [expletive deleted] clue... On Wed, Jun 22, 2011 at 3:49 PM, Nicholas Efremov-Kendall < [email protected]> wrote: > Hi all, > > I'm still trying to crack this nut, and to do so, I decided to strip out > the need for any transformations, assuming that since both the w3c geoloc > and twitter api's both use epsg 4326 natively. The geolocation works fine, > without any issues, but the tweets still aren't being plotted in the correct > place and I don't really know why. I've got an alert set on the point that's > created, and from what I can tell it is being fed valid coordinates, the > alert returns the following POINT(38.6315 -90.3462). I've plotted the coords > by hand, and can verify that they're coming from the right area What I have > noticed is that the coordinates seem to served as lat-long, rather than > lon-lat (i.e. tweet.geo.coord[0] = lat), but reversing the coordinates > doesn't result in markers getting added to the map, although the coords are > returned in the right order. > > Now, as near as I can tell, this problem has to be with the coordinates > being passed to my script from the twitter api itself. Maybe this has to do > with the coords getting passed to me in the wrong data type, but at this > point I'm stumped. > > full code is below > > > var tweetz = new OpenLayers.Layer.Vector("Tweets", {styleMap: new > OpenLayers.StyleMap({externalGraphic: > "OpenLayers-2.11-rc1/img/marker-green.png", pointRadius: 10})}); > var marker = new OpenLayers.Layer.Vector("Marker", {styleMap: new > OpenLayers.StyleMap({externalGraphic: "OpenLayers-2.11-rc1/img/marker.png", > pointRadius: 10})}); > var map = new OpenLayers.Map('map'); > var tweets = []; > var tweetsQ = []; > var refreshQuery = '?='; > function initGIS(){ > map.addControl(new OpenLayers.Control.LayerSwitcher());var wms = new > OpenLayers.Layer.WMS( > "OpenLayers WMS", > "http://vmap0.tiles.osgeo.org/wms/vmap0", > {'layers':'basic'} ); > map.addLayer(wms); > map.addLayer(tweetz); > map.setCenter(new OpenLayers.LonLat(-90, 38),12); > $(document).everyTime('30s', acquireTweets); > $(document).everyTime('100ms', parseTweetsQ); > getLoc(); > } > > function getLoc(){if (Modernizr.geolocation) { > navigator.geolocation.getCurrentPosition(plotLoc,handle_error);} else > {yqlgeo.get('visitor',norm_yql_resp);}} > > function createTWTsrcURL (){ > var temp = map.getCenter(); > return 'http://search.twitter.com/search.json' + refreshQuery + > '&geocode=' + temp.lat +'%2C' + temp.lon + '%2C50km&rpp=100&callback=?'; > } > > function plotLoc (position){ > map.addLayer(marker); > var feat = new OpenLayers.Feature.Vector(new > OpenLayers.Geometry.Point(position.coords.longitude,position.coords.latitude)); > marker.addFeatures([feat]); > var bounds = marker.getDataExtent(); > map.zoomToExtent(bounds); > acquireTweets(); > } > > function acquireTweets(){ > $.getJSON(createTWTsrcURL(), function(data){ > if(data.results) > $.each(data.results, function(i, tweet){ > if (tweet.geo || tweet.location) > tweetsQ.push(tweet); > }); > refreshQuery = data.refresh_url; > });} > > function parseTweetsQ(){ > if (tweetsQ.length > 0) { > var tweet = tweetsQ.pop(); > if (tweet.geo){ > tweet.point = new > OpenLayers.Geometry.Point(tweet.geo.coordinates[0],tweet.geo.coordinates[1]); > tweet.attributes = {}; > plotTwt(tweet);}}} > > function plotTwt(tweet){ > alert(tweet.point); > var twtfeat = new OpenLayers.Feature.Vector(tweet.point); > tweetz.addFeatures([twtfeat]); > } > >
_______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
