View unanswered posts | View active topics It is currently Mon Apr 23, 2018 8:54 am



Reply to topic  [ 3 posts ] 
Location Capture Widget - displaying data 
Author Message
ANDS Partners

Joined: Tue Feb 11, 2014 3:13 pm
Posts: 4
Hi

I was wondering if there is a code snippet to display the data returned from the Location Capture Widget?

IE As it is displayed on a view such as here http://researchdata.ands.org.au/theatreworks-archive


Thanks

Aaron


Wed Feb 12, 2014 10:00 am
Profile
ANDS Staff
User avatar

Joined: Sat Mar 26, 2011 10:57 am
Posts: 1
Hi

The location capture widget can and will return a lonlat string with a return callback, so you can do something like:
Code:
$('#map_widget').ands_location_widget({
 return_callback: function(data){
  alert(data);
 //data is the lonlat string when complete the drawing in the widget
 }
})


The location capture widget also provides a way to put the lonlat string in a new widget
Code:
$("#map_widget").ands_location_widget({
   lonLat:"151.503462,-33.251348 150.558638,-33.039778 149.767623,-34.137978 150.844283,-34.754050 151.283736,-33.937689 151.503462,-33.251348"
});


To achieve something like http://researchdata.ands.org.au/theatreworks-archive, you will need the lonlat string and knowledge on how to use the google map API, so basically we draw the lonlat string using polygons. You can view the open sourced code here in the drawMap() function https://github.com/au-research/ANDS-Registry-Core/blob/master/applications/portal/view/assets/js/view.js

Try that and let me know if you need any help
Regards,
Minh


Fri Feb 14, 2014 11:16 am
Profile
ANDS Partners

Joined: Tue Feb 11, 2014 3:13 pm
Posts: 4
Thanks, got it working.

Basically I used CSS
---------------------
#spatial_coverage_map {
width: 440px;
height: 320px;
margin-bottom: 10px;
margin-top: 10px;
}

#spatial_coverage_map div {
margin-bottom: 0px;
}
--------------------
<html>
<head>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=drawing&amp;sensor=false"></script>
<script type="text/javascript" src="/js/jquery/jquery-1.10.2.min.js"></script>
<link rel="stylesheet" href="/js/blah.css" type="text/css" media="screen">
<script type="text/javascript">
$(document).ready(function() {
drawMap();
function drawMap(){ //drawing the map on the left side
...
}

function stringToLatLng(str){
...
}
});
</script>

</head>
<body>
<div id="spatial_coverage_map"></div>
<p class="coverage hide">136.406250,-19.864894 131.835938,-25.378772 146.953125,-29.434814 136.406250,-19.864894</p> /*sample coordinates */
</body>
</html>


Wed Feb 19, 2014 4:50 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.