Hot answers tagged javascript
15
If you want a clusterer like redfin then check out my Leaflet.markercluster:
http://danzel.github.com/Leaflet.markercluster/example/marker-clustering-realworld.388.html
https://github.com/danzel/Leaflet.markercluster
It is fully animated etc etc :)
10
Yes. You are looking for the Geolocation API, here's a simple demo. Here is sample code from Dive Into HTML5 and HTML Rocks. Works great from web pages hosted on iOS and Android phones, it's a simple API to use. Strictly speaking it's not GPS; it's a generic location API. On mobile devices like iPhones location is often provided by WiFi or cell tower fixes ...
7
Nokia owns Navteq (acquired in 2008 for $8.1bn)
4 Tile Servers with pre caching
1.maptile.lbs.ovi.com/maptiler/v2
2.maptile.lbs.ovi.com/maptiler/v2
3.maptile.lbs.ovi.com/maptiler/v2
4.maptile.lbs.ovi.com/maptiler/v2
They do generate their own tiles from this vector data into raster tiled png format (256px x 256px) files
one example is
...
7
GetFeature control designed for retrieve features from a server and fires events that notify applications of the selected features. In your case you should use SelectFeature control:
selectFeature = new OpenLayers.Control.SelectFeature(
vectorLayer,
{
onSelect: clickNotice,
autoActivate: true
}
);
map.addControl(selectFeature);
...
7
You need to call the API to update map size.
http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.updateSize
Here's how we do it
window.onresize = function()
{
setTimeout( function() { map.updateSize();}, 200);
}
You can see we did a slight delay, and honestly I don't remember the exact reason why, but we had to give it a slight ...
7
Many people use OpenLayers as the map source, and doing a Google search for "OpenLayers jquery" provides three promising hits on the first page:
MapQuery, Combining the powers of OpenLayers and jQuery.
A plugin to combine JQuery and OpenLayers | Geodan Research
jquery-openlayers - jQuery UI plugin that wraps up OpenLayers API
6
The JS API makes extensive use of JSONP, and this is how service metadata is retrieved. Once the JS API knows about a map service, it can insert tags to display map tiles or images from dynamic map services.
You're correct that there are certain cases where a proxy is required. You can read up about them in the "Using a Proxy" section of the Inside ...
6
What you want to do (Convert address to a position) is called Geocoding. To get a a location for your address, you need a Geocoder.
Your Options are rather limited when you are working in the FOSS world. You main options are Nominatim & MapQuest's Open Geocoding Service
if you were working with Google's Map API, you could have used their Geocoder. ...
6
From the sounds of it you are trying to put down 1500 vector markers onto an OpenLayers map. Am I right? If this is the case then I would strongly suggest using some other method to display your vector features, as 1500 vectors in an OpenLayers map is a lot and will cause the browser to slow down and even crash altogether. The differences between browsers in ...
5
Depending on your acceptance of Google's licensing terms the Geomap is a good fit. It doesn't rely on OpenLayers (but I agree with @mwalker and @Carsten that OL is top notch), you can add your own text, it has a hover effect, and the aesthetic is quite nice.
5
In a similar vein to OpenLayers, another choice is http://leaflet.cloudmade.com/. Aside from its technical merits, it's very popular right now. It can be used easily with jquery, as an example at http://projects.bryanmcbride.com/leaflet/jqleaflet/ shows.
5
I've used this event successfully. A delay method similar to the one here can help any thrashing. The actual method looks like this:
delay: function( timeout, id, callback )
{
this.delays = this.delays || [];
var delay = this.delays[ id ];
if ( delay )
{
clearTimeout ( delay );
...
5
You should never display millions of points on a map. Not only because of the major performance problems, but also from a user's perspective because for them it most certainly will be difficult to interpret this data. Use some means of aggregating the data (clustering, aggregating to polygon areas etc.) combined with different display types at different zoom ...
5
I think it's because addLayers expects an array of layers. If you just want to add a single layer, you should use map.addLayer instead. Or you could give addLayers what it wants:
map.addLayers([googleStreetMap]);
I hope that helps.
5
You can pass an array of layers to the select control
selectControl = new OpenLayers.Control.SelectFeature(
[lineLayer, pointLayer],
{
clickout: true, toggle: false,
multiple: false, hover: false,
toggleKey: "ctrlKey", // ctrl key removes from selection
multipleKey: "shiftKey" // shift key adds to selection
}
);
...
5
If you want to finecontrol / test this deeper, outside what any framework (jquery/dojo) has to start this. You could try this little library:
var stack = [],
interval,
loaded; // has window.onload fired?
function doPoll() {
var notFound = [];
for (var i=0; i<stack.length; i++) {
if (document.getElementById(stack[i].id)) {
...
5
I would consolidate all of those dojo.addOnLoad() calls. I suspect something isn't getting loaded before a function is getting called.
Strip all dojo.addOnLoad calls from all of your external javascript files and bundle them into one call in your main HTML file. Put all the functions you want to fire on load into a new function at the bottom of your ...
5
When you unzip the file, there is a 135 kB minified GeoExt.js in the GeoExt/script folder.
The Development version is present at the GeoExt/lib/GeoExt.js location,
while the compressed & minified version is located at GeoExt/script/GeoExt.js.
5
As far as I know, there's two problems in this code. First one is, both Query and QueryTask doesn't define outputSpatialreference parameters. So this query returns there own spatialreference geometries instead of map's spatialreference.
tasks.Query...
queryContentSelect.outSpatialReference = map.spatialReference;
tasks.QueryTask...
...
5
Checkout the utility functions in the esri.geometry namespace. You can do areas and lengths client side with functions from there. You can also do point-in-polygon client side with polygon.contains (also see extent.contains).
4
I know this question was asked long ago, but since I recently had the same issue when working with DrawFeature I figured that I would provide my findings in case anybody else also had trouble.
I solved being able to manipulate the Handler's callbacks by digging through the source code. DrawFeature stores the handler instance in its "handler" property, and ...
4
It looks to me like you need to perform the trigonometry in radians not degrees. You use a function toDeg() so presumably you have one called toRad() (or possibly fromDeg() if you're odd). Call that function with your latitude and longitude values before the calculations, and you should be set.
Edit
I just tried this in Python (the syntax isn't dissimilar ...
4
Found my problem and I feel like a complete moron for my screw up seeing as how I've used this function so many times before.
PolylineQuery.where = 'where 1 = 1';
the above line should be
PolylineQuery.where = '1 = 1';
I don't need to specify the word 'where'
I'm an idiot :)
4
Yes, use map.updateSize() as Vadim says (also not sure why the delay!)
documentation
I commonly put a fullscreen toggle button on maps, which works simply by switching the css class of the map container and then calling updateSize()
function toggleFullScreen(mapContainer) {
if ($(mapContainer).hasClass("normal")) {
...
4
JSTS is a port of the Java Topology Suite, if it is a faithful port then it should support providing a negative value for the buffer distance. Providing a negative value for the buffer distance will create an inner buffer of the polygon, providing a negative value for a Point or Polyline will create a an empty geometry object.
The challenge is going to be ...
4
See the map events. http://dev.openlayers.org/docs/files/OpenLayers/Map-js.html#OpenLayers.Map.events
You want moveend and zoomend.
4
If you find yourself taking another look at OpenLayers, you can have a look at this app I did using jquery, jquery ui, and yes OpenLayers. I chose to select with a click as opposed to a hover. The popups seem to flash a bit to much for me.It's easy to change in setting up, hover: true.
bct.capecodgis.com, It's simple but gets the job done. Just click on a ...
4
The Resize, as @Mapperz mentioned is probably the way to go.
Alternatively, If you have lots of points, rather than looping through all the points resizing them, you could change the layer's pointRadius style on map zoom so the change happens to all features in one call. I can't say for sure what is better performance, but I would imagine changing the ...
4
You can use OpenLayers.Map.updateSize method to redraw your base Layer when you maximize the map.
So, adding a function like:
var fullScreen = function () {
map.baseLayer().redraw();
}
you would only need to add an additional option to your map:
var map = new OpenLayers.Map({
div: "map",
center: new OpenLayers.LonLat(0, 0),
updateSize: ...
4
Have you looked into the leaflet clusterer? A blog post by the author describes it
here
Another option worth a look may be to use leaflet in combination with GIS Cloud. Take a look at this demo to see it handle a lot of geometries very quickly. Very impressive. I am in no way affiliated with GISCloud.
Only top voted, non community-wiki answers of a minimum length are eligible


