Multi Kml Layer on Google maps - maps

I have developed a simple google map web page. I need help form anyone who has experience in google maps. In right panel of my web page I add some checkboxes and I want to link different kml with these checkboxes. When I check all layer all kml are show in google maps and when I uncheck any layer checkbox then kml related to that checkbox will disappear. Please guide me how I can do this.
Please check the page from this link
http://toptrippk.com/webgis/kml%20layers.html

I suggest you the following structure. Using this method you don't have to write seperate functions for every layer but only this one. Note that 'id' of 'input' tags here is used as KML filename. You probably want to see this question. If looking forward then geoxml3 may be an option for you.
var G = google.maps;
function toggle() {
if (!this.kml)
{this.kml = new G.KmlLayer('http://toptrippk.com/webgis/uploadfiles/kml/' + this.id + '.kml', {preserveViewport:true}); this.on = false};
if (this.on)
{this.kml.setMap(null); this.on = false} else {this.kml.setMap(map); this.on = true};
};
function initialize() {
var layers = document.getElementsByTagName('input');
var options = {};
map = new G.Map(document.getElementById('map_canvas'), options);
for (var i=0; i<layers.length; i++) {G.event.addDomListener(layers[i], 'click', toggle)};};
G.event.addDomListener(window, 'load', initialize);

Related

Cannot link to a webpart on SPO page with certain parameters

I have created a hyperlink which opens up a modal that shows a specific item from a SharePoint Online list.
Here's what I've got so far (with help from AmosWu!):
private _filterListOnEmail = () => { //this runs on componentdidmount
var urlParams = new URLSearchParams(window.location.search);
var urlParamstoString = urlParams.toString();
var justUrl = window.location.href;
var trimHref = justUrl.split('&')[0];
var trimHref2 = trimHref.substring(trimHref.indexOf("=") + 1);
var txtUrlParams = urlParams.toString();
var trimtxtUrlParams = txtUrlParams.substring(3);
this.setState({
urlParams: trimHref2
}, () => {
if(urlParamstoString){
this.setState({
showWelcomeModal: true,
ByEmail: 'Yes',
});
}
The URL I have constructed:
<a href={`https://mytenant.sharepoint.com/sites/MySite?ID=${this.props.id}`}>Here</a>
This works if the URL is https://mytenant.sharepoint.com/sites/MySite?ID=1 and it shows my modal and it gets the correct ID and shows the correct list item. But if it's ID=2 or any other number, the page shows No item exists at
https://mytenant.sharepoint.com/sites/MySite/SitePages/Home.aspx?ID=2
I don't understand why it's putting the extra SitePages/Home.aspx on the end....I guess this is causing the No item exists error.
The webpart is on the home page of the SP site.
It works with any ID number in workbench but not when deployed.
Really need help with this.
My test result:
I show the editform in the modal, it works well.
The code is the code I shared with you in Q&A. If you need the complete project code, please let me know and I will share it on Github.

Migrating jQuery selector to angularjs for third party vendor client help functionality

I'm trying to migrate old jQuery code to angularjs.
The issue that I'm having is that I'm not sure on the best approach.
Bascially, depending on the selector a different type of 'event' needs to be pushed into a array called gt.
The purpose of the jQuery code is to provide detailed info of clients having issues while filling in a form. the gt array is picked up by third party software that helps the clients by asking if they want to chat.
Example of how the array is populated:
$('a').live('click', { element: this }, function (element) {
_clickedElement = this;
var linkUrl = element.currentTarget.hostname + element.currentTarget.pathname;
var querystring = window.location.search
var shortLocationUrl = window.location.href.replace(querystring, "").replace("http://", "").replace("https://", "");
if (element.currentTarget.hostname.length > 0 && element.currentTarget.target != "_blank" && linkUrl != shortLocationUrl) { //click on a link that opens in the current window and points to a page external to this part
_gt.push(['event', { eventName: 'Leave_Page_' + chat.name, name: chat.name, pageName: chat.pageName, locale: _locale, isClient: chat.isClient }]);
_pushLeavePageEvent = false;
}
else if (this.id == backButtonId) { //click "previous"
_gt.push(['event', { eventName: 'Go_Back_' + chat.name, name: chat.name, pageName: chat.pageName, locale: _locale, isClient: chat.isClient }]);
_pushLeavePageEvent = false;
}
return true;
});
So for all the a tags inside my page (or form) the above code needs to be executed.
What would be a good approach to have similar behaviour in Angularjs?
I was thinking of a directive but I'm not sure whether to make this a directive at the level of my form or make a directive that I then use throughout my page?
P.S.: similar behaviour is needed (pushing an event into the gt array) for all the input, textarea and select fields on the page as well as the errors on the page caused by the clients and when a client hovers over a tooltip.

Capturing click events on clusters with markercluster and angular-leaflet-directive

I'm playing with the angular-leaflet-directive, and getting the marker names from a mouse click is straight forward. I just listen for the leafletDirectiveMarker.click event and then access args.markerName.
angular-leaflet-directive also works with markercluster, so I can cluster markers that have the same coordinates or ones that are close by. However, I would like to do the following, but it is not clear from the documentation on how to do it:
Make user double-click on cluster to zoom in. Currently doing a single click on a cluster will zoom in on the markers. see example.
How to listen for click event on cluster and get all marker names in the cluster.
The documentation for clustermarker has a cluster event:
markers.on('clusterclick', function (a) {
console.log('cluster ' + a.layer.getAllChildMarkers().length);
});
But I'm not sure what event I should be listening to using angular-leaflet-directive.
As far as your first question goes, you'll have to hook the doubleclick and pass it the fire('click') command after overriding the usual click event. Probably more trouble than its really worth, especially on mobile - and not something I can easily solve.
Regarding your second question, I have just solved it.
$scope.openMarker is a reference to an ng-click event in my jade template that is attached to an ng-repeat which pulls images and their id's from the database.
$scope.openMarker = function(id) {
var _this = [];
_this.id = id;
leafletData.getMarkers()
.then(function(markers) {
$scope.london = {
lat: $scope.markers[_this.id].lat,
lng: $scope.markers[_this.id].lng,
zoom: 19
};
var _markers = [];
_markers.currentMarker = markers[_this.id];
_markers.currentParent = _markers.currentMarker.__parent._group;
_markers.visibleParent = _markers.currentParent.getVisibleParent(markers[id]);
_markers.markers = markers;
return _markers;
}).then(function(_markers){
if (_markers.visibleParent !== null) {
_markers.visibleParent.fire('clusterclick');
} else {
_markers.currentMarker.fire('click');
}
return _markers;
}).then(function(_markers){
_markers.currentParent.zoomToShowLayer(_markers.markers[ _this.id ], function() {
$scope.hamburg = {
lat: $scope.markers[_this.id].lat,
lng: $scope.markers[_this.id].lng,
zoom: 19
};
if (_markers.currentMarker !== null) {
_markers.currentMarker.fire('click');
} else {
_markers.visibleParent.fire('clusterclick');
_markers.currentMarker.fire('click');
}
});
});
};
You can read more about how I came to this solution here at github.
Much like many people, I too had a long search with no results. While experimenting with another method, I came across this:
$timeout(function(){
leafletData.getLayers().then(function(layers) {
$scope.markerClusterGrp = layers.overlays.locations;
var clusters = $scope.markerClusterGrp.getLayers();
$scope.markerClusterGrp.on('clustermouseover', function (a) {
var clusterObjects = a.layer.getAllChildMarkers();
console.log(clusterObjects);
});
$scope.markerClusterGrp.on('clusterclick', function (a) {
var clusterObjects = a.layer.getAllChildMarkers();
console.log(clusterObjects);
});
});
},1000);
It works the same, the difference is that it requires a timeout in order to wait for the layer to render with all markers (my understanding, correct me if wrong :-) ).
I hope this helps anyone searching for an angular solution. Just remember to include $timeout in your controller dependencies.

Angularjs Google charts event listener

I am trying to make my google chart interactive using angularjs. I am using this AngularJs Google Chart directive https://github.com/bouil/angular-google-chart
I tried several options to add Listener by going through some examples.
$scope.selectListener = google.visualization.events.addListener($scope.chart, 'select', function () {
$scope.$apply(function(){
var selectedItem = $scope.chart.getSelection()[0];
if (selectedItem) {
var topping = $scope.chart.data.getValue(selectedItem.row, 0);
alert('The user selected ' );
}
})
});
I am seeing these errors in my browser
Error: [$interpolate:interr] http://errors.angularjs.org/1.2.8/$interpolate/interr?p0=%24scope.chartObje…json%7D%7D&p1=TypeError%3A%20Converting%20circular%20structure%20to%20JSON
at Error (native)
Can someone please help me with an example how to make google chart interactive using angularjs?
Here is some more information which I would like to share:
chart1.type = "ColumnChart";
chart1.displayed = false;
var chdata = new google.visualization.DataTable();
chdata.addColumn('string', 'Task');
chdata.addColumn('number', 'Passed');
chdata.addColumn('number', 'Failed');
for( var i=0; i<queueDet.length; i++){
chdata.addRow([queueDet[i].rundate, {v: queueDet[i].passedTestCount, f: queueDet[i].buildTag}, {v: queueDet[i].failedTestCount}]);
}
In this column chart I would like to make those columns interactive and when I click Passed column, would like to make an $http call by passing queueDet[i].buildTag to get additional details and render them in a table.

Appcelerator Titanium Mobile App Screens?

I am trying to figure out how to make a multi-screen app using Appcelerator Titanium. I am familiar with Android development, so using the Android SDK I would create a few different activities, each doing their different work (login screen, screen displaying list of items, etc.) What is the equivalent in Titanium? I know that app.js is the main part of the app, but I assume it is not recommended to just put all code in that single file. The kitchen sink app has a lot of files and functionality, but I am not sure how they all fit together. So, what is the recommended way to create a project in Titanium for a basic app with a few screens doing different things? I am missing the Titanium concept of a screen.
no..
you can do it like
var button = Ti.UI.createButton({..});
button.addEventListener('click',function(e){
var window = Ti.UI.createWindow({
url:"../newWindow.js",
title:"newWindow"
});
Titanium.UI.currentTab.open(window,{animated:true});
});
i recommend to use the MVC-pattern like i already posted here.
App.js file is basically the file to initialize different window screens, and use Tabs to load those windows screens.Here is a link to create simple screens Create Window & Tabs
For further properties related to TitaniumUI
Try doing this:
app.js
Tintanium.include('window1.js', 'window2.js');
...
var button1 = Titanium.UI.createButton({...});
button1.addEventListener('click',function(){
window1.open();
});
window1.js
var window1=Titanium.UI.createWindow({...});
...etc...
Hope this will help ;)
try using my code below:
// functions
function openHomescreen(e)
{
settings.close();
getlucky.close();
survey.close();
homescreen.url = 'homescreen.js';
homescreen.open();
}
function openGetlucky(e)
{
settings.close();
homescreen.close();
getlucky.url = 'getlucky.js';
getlucky.open();
}
// events
Ti.App.addEventListener('homescreen',openHomescreen);
Ti.App.addEventListener('getlucky',openGetlucky);
openHomescreen({});
To open homescreen in other JS file, use this.
Ti.App.fireEvent('homescreen');
After a lot of time research i i found the solution for opening different windows with a click event attached to a button.
employee.js
//Current window (employee window)
var employeeWin = Ti.UI.currentWindow;
//define button
var moveToDetailBtn = Ti.UI.createButton({
width : 200, //define the width of button
height : 50, //define height of the button
title : 'Show Detail' //Define the text on button
});
//Click event to open the Employee Details window
moveToDetailBtn.addEventListener('click', function(){
//Call a export function
var win = require('employeeDetails').getEmployeeDetailSWin;
//Create new instance
var employeeDetailsWin = new win();
//Open the Employee Details window
employeeDetailsWin.open();
});
//Add the button to the window
employeeWin.add(moveToDetailBtn);
In employeeDetails.js
exports.getEmployeeDetailSWin = function(){
//Creates a new window
var empDetailsWin = Ti.UI.createWindow({
backgroundColor : '#ffffff' //Define the backgroundcolor of the window
});
//Addin a label to the window
empDetailsWin.add(Ti.UI.createLabel({
width : 100, //Define width of the label
height : 50, //Define height of the label
title : 'Employee Details'
}));
return empDetailsWin;
};
I found the solution in this page: http://www.mindfiresolutions.com/Open-New-Window-Without-URL-Property-In-Titanium-2214.php

Resources