How to embed leaflet map to html page? - html

I'm new with web developing, and I want to embed a map to my html page.
How I can do this?
I'm using leaflet map generated from QuantumGIS with qgis2leaflet plugins.
In the future, I want to show a heat graph in the map that represent population distribution.
this is my html code:
<div class="widget span8">
<div class="widget-header">
<i class="icon-map-marker"></i>
<h5>Map Visualization</h5>
<div class="widget-buttons">
</div>
</div>
<div class="widget-body clearfix">
<div style="height:274px;" id="graph" class="widget-analytics-large"></div>
</div>
</div>
</div>

Have a look here: http://leafletjs.com/examples/quick-start.html
This is an example page: http://leafletjs.com/examples/quick-start-example.html
generally, you would have to add a placeholder div for your map in the body
<div id="my-custom-map" style="width: 600px; height: 400px"></div>
and then create the leaflet map via the Javascript API:
var map = L.map('my-custom-map').setView([51.505, -0.09], 13);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6IjZjNmRjNzk3ZmE2MTcwOTEwMGY0MzU3YjUzOWFmNWZhIn0.Y8bhBaUMqFiPrDRW9hieoQ', {
maxZoom: 18,
attribution: 'Map data © OpenStreetMap contributors, ' +
'CC-BY-SA, ' +
'Imagery © Mapbox',
id: 'mapbox.streets'
}).addTo(map);
Note that you are using the id of the element (my-custom-map) to create the leaflet map within that div

Related

Iframe content does not load in Html widget in Flutter

I am using Html Widget to show article content in Flutter andriod app.Content is mixed html tag and contains some video embeded using iframe. Widget display a loading circle for a few seconds and after that nothing shown.
Flutter version 3.3.3
flutter_html: ^3.0.0-alpha.6
Sample Code expected to show in app:
<h3>View more</h3>
<p>This is a sample code for article and video inside artcle body</p>
<div class="h_iframe-aparat_embed_frame"><span style="display: block;padding-top: 57%"></span><iframe src="https://www.aparat.com/video/video/embed/videohash/q0IdU/vt/frame" allowFullScreen="true" webkitallowfullscreen="true" mozallowfullscreen="true"></iframe></div>
<p>Click to view more video</p>
Have you try this?
var html = '''
<iframe width="1200" height='710'
src="$videosid" </iframe>
''';
Column(children:[
**HtmlWidget(html)** OR
InAppWebView(
InAppWebViewInitialData(data: '${html}'),
initialUrlRequest: URLRequest(
url: Uri.parse("${videosid}" ?? ''),
),
),
]
)

Iterate array inside html

I am developing a product sale page. I have used a jquery plugin for implementing a carousel image.
Thats the library:
https://www.jqueryscript.net/demo/Carousel-Plugin-jQuery-RV-Gallery/
I am using the image statically for testing, with some images from internet. But I have to store the images dynamically, so amb I trying to iterate an ARRAY inside html. That array is html formatted.
I need to replace the shopify links, for the content of the arrayImagesProduct. Each product, it may have one, two, three,.. images. So I need to iterate the array .
I have tried this:
$("#productImages").html(arrayImagesProduct.join(''));
but then the slider it doesnt work. I get this error:
Uncaught TypeError: Cannot read property 'clientWidth' of undefined
at Gallery.countMoveRight (RV-gallery.js:121)
at RV-gallery.js:36
at dispatch (VM1025 jquery-1.12.4.js:5226)
at elemData.handle (VM1025 jquery-1.12.4.js:4878)
function showProduct(productCode){
var arrayImagesProduct = [];
$.post('../ServletJson', {
elem : 'productInfo',
code: productCode,
}, function(data) {
$.each(data,function(t,elem){
/* some stuff */
arrayImagesProduct.push('<img class="gallery-item" src="../loadImgProduct.jsp?idImg='+elem.idImg+'&code=productCode">');
});
$("#productImages").html(arrayImagesProduct.join(''));
});
}
How I can iterate the arrayImagesProduct array inside the html?
Inside here
<div class="gallery" id="productImages">
<!-- iterate arrayImagesProduct -->
<\div>
<body>
<div class="container-fluid">
<div class="row image-gallery-container">
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 ">
<div class="gallery" id="productImages">
<img class="gallery-item" src="https://cdn.shopify.com/s/files/1/0122/2724/8185/products/0719_2019_Top1_b_ae870642-af0d-4655-811d-d597ed2a8bcc_720x.jpg?v=1574239406">
<img class="gallery-item" src="https://cdn.shopify.com/s/files/1/0122/2724/8185/products/0719_2019_Top1_a_720x.jpg?v=1574239409">
</div>
</div>
</div>
<!-- more content -->
</div>
</body>
Uncaught TypeError: Cannot read property 'clientWidth' of undefined
at Gallery.countMoveRight (RV-gallery.js:121)
at RV-gallery.js:36
at dispatch (VM1025 jquery-1.12.4.js:5226)
at elemData.handle (VM1025 jquery-1.12.4.js:4878)
The carousel is instantiating doing the declaration:
<div class="gallery">
jQuery('.gallery').eq(0).initGallery({
nav: ['<i class="material-icons">keyboard_arrow_left</i>', '<i class="material-icons">keyboard_arrow_right</i>'],
close: "<i class='material-icons'>close</i>",
aspectRatio: 3/2,
showDots: true,
showNavIfOneItem: false,
showNav: false,
arrows: true,
transition: "slide",
transitionTime: 700,
});
jQuery.fn.initGallery = function(options) {
if(!options) {
options={};
}
var galleries=[];
for (let i=0; i<this.length; i++) {
options.gallery = this.eq(i);
galleries[i] = new Gallery(options);
}
};

HTML icons mapping based on data value

I am creating a weather web app based on API from openweather.com using Spring-Boot and Angular.
I am also using this weather-icons package.
In my HTML file weather icons are displayed like this:
<div class="jumbotron">
<i class="wi wi-snow" style="font-size: 8em;"></i>
<i id="description">{{weather.weatherID}}</i>
</div>
With the help of API I have also weather code value available in html.
Let's say I have a file weather.data with weather codes mapped to icon description like this:
601: snow
602: sleet
611: rain-mix
Is it possible to display certain icon in HTML based on value in data file?
What I want to do is something like:
<div class="jumbotron">
<i class="wi wi-{{weatherDescription}}" style="font-size: 8em;"></i>
</div>
You can get your data from weather.data in a scope variable.
It would be like:
In Controller:
$http.get(path of weather.data file, null, function(response){
$scope.weatherList = response; //do angular.fromJson if required
});
I hope you are getting a JSON object as :
$scope.weatherList = {
601: "snow",
602: "sleet",
611: "rain - mix"
}
If you are getting weather code from server side in weatherDescription, then you can use it like this on html :
In Html:
<div class="jumbotron">
<i class="wi wi-{{weatherList[weatherDescription]}}" style="font-size: 8em;"></i>
</div>
I hope this works for you.

how to refresh previous page on <ons-back-button> click

Hello i am working on onsen ui with angularjs and have made a demo app which includes google maps,All things were working smootly,But after testing i found an issue on ons-back-button,Please see the case,I have page1 which containc google maps and when page loaded first time map is completely loaded fine,but from page1 when i navigate to page2 and returns back to page1 using (ons-back-button) ,my map broken and never loaded..I have wasted my 3 days in solving this,with no luck,can anyone please help me how to solve it,my code is:
html
<div class="mapclass">
<ons-row class="app-map">
<ons-col>
<map zoom="11" center="[{{lat}}, {{lng}}]"
draggable: false >
<info-window id="marker-info" >
<div class="mpopup-wrap" style="padding: 0; width: 250px;">
<div class="mpopup-box">
<strong class="title">{{ infoWindow.title}}</strong>
<img src="{{mapimg}}" style="float: left; width: 80px; height: 53px; margin-right: 5px;" />
<span class="info">
<i class="fa fa-map-marker"></i>
{{infoWindow.loc}}
</span>
<span class="info">
<i class="fa fa-home"></i>
{{infoWindow.content}}
</span>
</div>
</div>
</info-window>
<marker ng-repeat="(id, marker) in markers" id="{{ id}}"
position="[{{lat}}, {{lng}}]"
title= "hello"
visible="true"
on-click="showMarker(event, $index)" >
</marker>
</map>
</ons-col>
</ons-row>
</div>
Try using prepop or postpop to execute or reload the goole maps.
Onsen docs (prepop, postpop)
I think this thread might be very connected to your issue. I'm not familiar with onsen, but what you would like to do anyways is to control the behavior from some controller, and with UI-route-provider, you could manage to control if page reloads on switch.
See the first answer here

Facebook Canvas with Unity Integration change unity config params

Hello i'm working on a facebook game using unity3D, in the past i could just add the html code with custom configuration into the facebook canvas, but now in the new sdk and integration with unity facebook directly loads the unity3d file, ignoring all my custom html code and custom configuration.
In the documentation says that i can add custom html code in unity by using the external calls, but that means that the html header and modifications will only appear after the game is loaded and runing, is there a way to have the html header while the game is loading.
and, how i can modify the default logoimage, progressbarimage, etc.
Here is the uinty configuration and the code i have on my html document that i want to apply on my facebook game.
var config = {
width: 1024,
height: 768,
backgroundcolor: "FFFFFF",
bordercolor: "383838",
textcolor: "FFFFFF",
logoimage: "Resources/loading.png",
progressbarimage: "Resources/Loading-Bar_Full.png",
progressframeimage: "Resources/Loading-Bar_Empty.png",
disableContextMenu: true,
params: { enableDebugging:"0" }
};
var u = new UnityObject2( { params: config } );
Html header WIP
<div id="header">
<span>-Beta Build- | </span> My Game <br/>
<img alt="Header!" src="Resources/WebHeader.png"/>
<div id="like">
<img alt="Like Us" src="Resources/WebLike.png"/>
</div>
<div id="store">
<img alt="Earn Credits" src="Resources/WebCredits.png"/>
</div>
<div id="gift">
<img alt="Send Gift" src="Resources/WebSendGift.png"/>
</div>
<div id="help">
<img alt="Help" src="Resources/WebHelp.png"/>
</div>
</div>
Thanks.