Perform visual queries using circles and rectangles to select a particular area or areas and the corresponding table data. Query a table simply by drawing a bounding shape on the map. The callback function will contain data from the area that corresponds to the table or query. If no table or query is provided a string description of the drawing will be returned.
<html>
<head>
<style type="text/css" media="all">
#datadiv {
height:300px !important;
overflow-y:scroll;
}
.mapdiv {
width:100%;
height:100%;
}
.ml-btn {
position:absolute;
top:80px;
left:45px;
}
</style>
<script type="text/javascript" src="/JS"></script>
<script type="text/javascript">
ml.onload(function() {
// create our map and hold a reference to it
var map=ml.map(document.getElementById('mapdiv'));
//Adding this layer is not required for the query to work, but
//helps users see where they are drawing their selection.
//
var layer = ml.layer(map,{
"onClick": "debug",
"query": {
"select": {
"type": "geo.dot"
},
"where": [],
"table": {
"name": "hms/hotels"
}
},
"style": {
"method": "rules",
"rules": [
{
"style": {
"shape": "round",
"height": "6",
"width": "6",
"fillColor": "204-86-86-255",
"borderColorOffset": "75",
"dropShadow": "false"
},
"where": "CatchAll"
}
]
}
});
layer.show();
ml.$('.wkt-response').hide();
// RegionSelect options object
// (map) [REQUIRED] reference to map
// (callback) [REQUIRED]
// (drawingType) [OPTIONAL default circle] either rectangle or circle
// (query) [OPTIONAL] If provided it will return an ml.query data set to the callback
// (table) [OPTIONAL] table to query using the drawing
// (take) [OPTIONAL default 1,000] number of rows to return from table query
// (query) [OPTIONAL] reference to a configured ml.query
var RegionSelectOptions = {
map: map,
drawingType: 'circle',
query: {
table: 'hms/hotels',
take: 1000
},
callback: function(data) { // data returned will be a Data JSON returned by ml.query
// display the results
ml.$('#datadiv').html(ml.util.JsonHighlight(data));
ml.$('#datadiv').dialog({"title": "Query Results"});
}
};
// ml.ui.map.RegionSelect takes one parameter, its Option object
var drawCircleForWkt = new ml.ui.map.RegionSelect(RegionSelectOptions);
// the beginDrawing() function triggers the drawing capabilities on the map.
// this is reusable and can be called as many times as needed.
ml.$('.ml-btn').on('click', function(e) {
drawCircleForWkt.beginDrawing();
});
});
</script>
</head>
<body>
<div id='mapdiv' class='mapdiv'></div>
<button class="ml-btn ml-btn-primary" id="region-select-trigger">
Select a Region
</button>
<div id='datadiv'></div>
</body>
</html>
<html>
<head>
<style>#datadiv {
height:300px !important;
overflow-y:scroll;
}
.ml-btn {
position:absolute;
top:80px;
left:45px;
}</style>
<script type="text/javascript" src="/JS"></script>
<script type="text/javascript">
ml.onload(function() {
var map = ml.map("mapDiv");
ml.$('.wkt-response').hide();
// define our initial query to send in for GeoQuery processing
var query=ml.query().select('*').from('hms/hotels').take(1000);
// RegionSelect options object
// (map) [REQUIRED] reference to map
// (callback) [REQUIRED]
// (drawingType) [OPTIONAL default circle] either rectangle or circle
// (query) [OPTIONAL] If provided it will return an ml.query data set to the callback
// (table) [OPTIONAL] table to query using the drawing
// (take) [OPTIONAL default 1,000] number of rows to return from table query
// (query) [OPTIONAL] reference to a configured ml.query
var RegionSelectOptions = {
map: map,
drawingType: 'circle',
query: {
query: query
},
callback: function(data) { // data returned will be Data JSON result from ml.query
// display the results
ml.$('#datadiv').html(ml.util.JsonHighlight(data));
ml.$('#datadiv').dialog({"title": "Query Results"});
}
};
// ml.ui.map.RegionSelect takes one parameter, its Option object
var drawCircleForWkt = new ml.ui.map.RegionSelect(RegionSelectOptions);
// the beginDrawing() function triggers the drawing capabilities on the map.
// this is reusable and can be called as many times as needed.
ml.$('.ml-btn').on('click', function(e) {
drawCircleForWkt.beginDrawing();
});
});
</script>
</head>
<body>
<div id="mapDiv" style="width:100%;height:100%;"></div>
<button class="ml-btn ml-btn-primary" id="region-select-trigger">
Select a Region
</button>
<div id="datadiv">
</div>
</body>
</html>
<html>
<head>
<style type="text/css" >
#datadiv {
height:300px !important;
overflow-y:scroll;
}
.mapdiv {
width:100%;
height:100%;
}
.ml-btn {
position:absolute;
top:80px;
left:45px;
}
</style>
<script type="text/javascript" src="/JS"></script>
<script type="text/javascript">
ml.onload(function() {
// create our map and hold a reference to it
var map=ml.map(document.getElementById('mapdiv'));
ml.$('.wkt-response').hide();
// RegionSelect options object
// (map) [REQUIRED] reference to map
// (callback) [REQUIRED]
// (drawingType) [OPTIONAL default circle] either rectangle or circle
// (query) [OPTIONAL] If provided it will return an ml.query data set to the callback
// (table) [OPTIONAL] table to query using the drawing
// (take) [OPTIONAL default 1,000] number of rows to return from table query
// (query) [OPTIONAL] reference to a configured ml.query
var RegionSelectOptions = {
map: map,
drawingType: 'circle',
callback: function(data) { // data returned will be MapLarge WKT representation of the drawing
// display the results
ml.$('#datadiv').html(ml.util.JsonHighlight(data));
ml.$('#datadiv').dialog({"title": "Query Results"});
}
};
// ml.ui.map.RegionSelect takes one parameter, its Option object
var drawCircleForWkt = new ml.ui.map.RegionSelect(RegionSelectOptions);
// the beginDrawing() function triggers the drawing capabilities on the map.
// this is reusable and can be called as many times as needed.
ml.$('.ml-btn').on('click', function(e) {
drawCircleForWkt.beginDrawing();
});
});
</script>
</head>
<body>
<div id='mapdiv' class='mapdiv'></div>
<button class="ml-btn ml-btn-primary" id="region-select-trigger">
Select a Region
</button>
<div id="datadiv"></div>
</body>
</html>
