Skip to content

Instantly share code, notes, and snippets.

@YoannArasLab
Created November 4, 2016 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YoannArasLab/7627397bb26c9ea0d07df34f0dd37c3a to your computer and use it in GitHub Desktop.
Save YoannArasLab/7627397bb26c9ea0d07df34f0dd37c3a to your computer and use it in GitHub Desktop.
<!--
Copyright (c) 2016 - Aras Corp
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html>
<head>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
</head>
<body style='width:100%;height: 100%;' >
<div id='MDL_GM' style='width:100%;height: 100%;' ></div>
<script>
var map;
var markers = [];
function initMap() {
map = new google.maps.Map(document.getElementById('MDL_GM'), {
zoom: 6,
center: {lat: 46, lng: 4},
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP]
}
});
google.maps.event.addListener(map, 'idle', function(ev){
var bounds = map.getBounds();
var latmin = bounds.getSouthWest().lat();
var latmax = bounds.getNorthEast().lat();
var longmin = bounds.getSouthWest().lng();
var longmax = bounds.getNorthEast().lng();
var innovator = top.Innovator();
var qryItem = top.aras.newIOMItem('geoItem', 'get');
qryItem.setAttribute("maxRecords","200");
qryItem.setAttribute("where","([geoItem].lattitude BETWEEN "+latmin+" AND "+latmax+" ) AND ([geoItem].longitude BETWEEN "+longmin+" AND "+longmax+" ) ");
var results = qryItem.apply();
var count = results.getItemCount();
var itemArray = [];
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(null);
}
markers = [];
for (var i=0; i<count; ++i){
var item = results.getItemByIndex(i);
var image = 'itemImage.png';
markers.push(new google.maps.Marker({
position: {lat: Number(item.getProperty("lattitude")), lng: Number(item.getProperty("longitude"))},
draggable: false,
title: item.getId(),
map: map,
icon : image
}));
var infowindow = new google.maps.InfoWindow({
content: "ID"
});
markers[i].addListener('click', function() {
var qryItem = top.aras.newIOMItem('demo_radars', 'get');
qryItem.setID(this.getTitle());
var results = qryItem.apply();
var thumbnailUrl = "itemIcon.jpg"
if ( results.getProperty("thumbnail")!== undefined){
console.log(results.getPropertyAttribute("thumbnail","is_null"));
var thumbnailId = results.getProperty("thumbnail").split("fileId=")[1];
thumbnailUrl = innovator.getFileUrl(thumbnailId,top.aras.Enums.UrlType.SecurityToken);
}
infowindow.setContent('<img src="' + thumbnailUrl+'" width="256px"/><p><b>lat:</b>'+results.getProperty("lattitude")+'</p><p><b>long:</b>'+results.getProperty("longitude")+'</p>' );
infowindow.open(map, this);
});
markers[i].addListener('dblclick', function() {
top.aras.uiShowItem("geoItem", this.getTitle());
});
}
});
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAHTQp30SwiJutXgVnGudQcPOSS0xGdzWg&signed_in=true&callback=initMap"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment