Hot answers tagged

2

You could use the CartoDB SQL API with CartoDB.js to call the data that you want to display depending on where the user click. In this section of the CartoDB documentation you can find more information about using theCartoDB SQL API within CartoDB.js. In this example you can find how a buffer is created everytime that a user clicks on the map and the points ...


2

You can switch your draw circle to a proper polygon using the ol.geom.Polygon.fromCircle api doc here. In that way jsts can understand the polygon and perform the intersection. Check the fiddle here to see it in action.


2

Might just need e.target or e.layer before feature.properties.name - console.log is your friend here and will likely answer your question.


2

You can use L.control, but there are only 4 positions: //logo position: bottomright, topright, topleft, bottomleft var logo = L.control({position: 'topleft'}); logo.onAdd = function(map){ var div = L.DomUtil.create('div', 'myclass'); div.innerHTML= "<img src='logo.png'/>"; return div; } logo.addTo(map);


2

I slightly changed your code, and this is working for me: var myStyle = { fillColor: '#1c9099', color: 'white', weight: 3 }; var polygon = L.polygon( [[51.509, -0.08], [51.503, -0.06], [51.51, -0.047]]); polygon.setStyle(myStyle).addTo(map); map.on('zoomend', function () { currentZoom = map.getZoom(); if (currentZoom == 15) {...


1

Instead of creating a tile layer inside your getTile callback, you'll have to create an ol.layer.Tile with an ol.source.XYZ and a custom tileUrlFunction and tileLoadFunction: new ol.layer.Tile({ source: new ol.source.XYZ({ tileUrlFunction: function(tileCoord) { // create a simplified url for use in the tileLoadFunction return tileCoord....


1

If the problem is that "feature.properties.name is undefined" just pass the feature into openSidedbar. And if you want to display "this is A" or "this is B" pass that feature parameter into html (assuming that sidebar is a jQuery object): UPDATE function onEachFeature(feature, layer) { layer.on({ mouseover: highlightFeature, mouseout: ...


1

You can try with L.Control.Credits plugin. A simple, attractive, interactive control to put your logo and link in the corner of your map. You can also easily do it yourself with JavaScript: var mapControlsContainer = document.getElementsByClassName("leaflet-control")[0]; var logoContainer = document.getElementById("logoContainer"); ...


1

Create a second style with bigger scale: style2 = [ new ol.style.Style({ image: new ol.style.Icon(({ scale: .9, opacity: 1, rotateWithView: false, anchor: [0.5, 1], anchorXUnits: 'fraction', anchorYUnits: 'fraction', src: '//cdn.rawgit.com/jonataswalker/map-utils/' + 'master/images/marker.png' })), zIndex: 5 }) ] ...


1

You can simply create a CQL filter that combines the elements that you need to select, so: CQL_FILTER=phase=1 AND grade='A' OpenLayers should take care of URL encoding it for you.


1

The route method does not pass any options on to the router. You'll want to use the getRouter method to set the router options first. Then you can recalculate using route: L.easyButton('<img src="pic.png">', function(btn,map){ myRouter.getRouter().options.costing = "pedestrian"; myRouter.route(); }).addTo(map);


1

Try defining your style like this: var myStyle = new ol.style.Style({ fill: new ol.style.Fill({ color: 'rgba(255, 100, 100, 0.3)' }), stroke: new ol.style.Stroke({ color: 'rgba(255, 80, 80, 0.9)' , width: 2 }), });


1

The layer that is to be toggled needs to be a global variable, thus making it available to the window[ ] object see here. I was creating the layer inside a function. I simply created the empty variables at the beginning of the script and it works. document.getElementById('chooser').addEventListener("click", function(e) { mapLayers.clearLayers(); layer =...


1

the variable layer will contain the e.target.id which is not a layer, I presume you have a table named layer somewhere and you want to get the layer with the index e.target.id to do so: var index=e.target.id; layer[index].addTo(mapLayers); If this is actually what you want to make


1

Check this block where the infowindows are added using a documented method, instead of directly modifying the properties of the layer. cartodb.vis.Vis.addInfowindow( map, sublayer, ['cartodb_id', 'lat', 'lon', 'name'], { infowindowTemplate: $('#infowindow_template').html(), templateType: 'mustache' } );


1

It seems you are running the update() on a new marker each time. You should store the marker after you've created it; And then run the update function on this same marker-object every time. This means you have to store the markers outside of fillMap(). Also, you need to handle the changes in connectivity: when a car goes offline, you have to remove the ...


1

you want to create a layer with a single feature so you must use: features: [features[0]]


1

Add an ol.interaction.Select to your map. It allows multi-selects (shift+click), and sends an array of selected and deselected features in its 'select' event. It uses an ol.Collection to store selection results. For instance: var int_select = new ol.interaction.Select({ features: new ol.Collection(); }); map.addInteraction(int_select); int_select.on('...


1

See the Readme about GeoJSON properties. The correct property name is height, not building:levels. building:levels is the corresponding tag in the OSM database but it is converted to a height property for the resulting GeoJSON data.



Only top voted, non community-wiki answers of a minimum length are eligible