Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(document).ready(function () {
- $('.tap-target').tapTarget('open');
- var typeSelect = 'None';
- <!-- Creating Basic Map -->
- var styles = [
- 'Road',
- 'Aerial',
- 'AerialWithLabels',
- 'collinsBart',
- 'ordnanceSurvey'
- ];
- var layers = [];
- var i, ii;
- for (i = 0, ii = styles.length; i < ii; ++i) {
- layers.push(new ol.layer.Tile({
- visible: false,
- preload: Infinity,
- source: new ol.source.BingMaps({
- key: '#mykey',
- imagerySet: styles[i]
- // use maxZoom 19 to see stretched tiles instead of the BingMaps
- // "no photos at this zoom level" tiles
- // maxZoom: 19
- })
- }));
- }
- var map = new ol.Map({
- interactions: ol.interaction.defaults().extend([new app.Drag()]),
- layers: layers,
- // Improve user experience by loading tiles while dragging/zooming. Will make
- // zooming choppy on mobile or slow devices.
- loadTilesWhileInteracting: true,
- target: 'map',
- view: new ol.View({
- projection: 'EPSG:4326',
- //center: [0, 0],
- //projection: 'EPSG:4326',
- center: [-48.669159, -26.904534],
- zoom: {{ geo|length > 0 ? 17 : 13 }}
- })
- });
- var select = document.getElementById('layer-select');
- function onChange()
- {
- var style = select.value;
- for (var i = 0, ii = layers.length; i < ii; ++i)
- {
- layers[i].setVisible(styles[i] === style);
- }
- }
- select.addEventListener('change', onChange);
- onChange();
- <!-- Creating Basic Map -->
- <!-- Draw Feature -->
- var source = new ol.source.Vector({
- wrapX: true
- });
- var fill = new ol.style.Fill({
- color: 'rgba(255,255,255,0.4)'
- });
- var stroke = new ol.style.Stroke({
- color: '#3399CC',
- width: 3
- });
- var sourceStyle = new ol.style.Style({
- image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
- anchor: [0.5, 36],
- anchorXUnits: 'fraction',
- anchorYUnits: 'pixels',
- src: '{{ asset('/images/material-icons/maps/1x_web/ic_place_black_36dp.png') }}'
- })),
- stroke: stroke,
- fill: fill
- });
- var vector = new ol.layer.Vector({
- //projection: 'EPSG:25830',
- style: sourceStyle,
- source: source
- });
- map.addLayer(vector);
- vector.setVisible(true);
- $.ajax({
- type: 'get',
- url: 'http://datosabiertos.malaga.eu/recursos/urbanismoEInfraestructura/sedesWifi/sedesWifi-25830.geojson',
- type: 'json',
- success: function (r) {
- // eval pode incomodar, verificar isso para evitar problemas, mas feito assim para testes
- //EPSG::3857
- //console.log(r);
- //console.log(new ol.format.GeoJSON().readProjection(r));
- var feats = (new ol.format.GeoJSON()).readFeatures(r);
- //I've tried to use featureProjection and dataProjection with no luck
- source.reportError = true;
- source.addFeatures(feats);
- }
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement