with 0 opacity lines there seems to be point features that show up at lower zooms but go away when you zoom in
Created
November 19, 2012 15:23
-
-
Save calvinmetcalf/4111248 to your computer and use it in GitHub Desktop.
0 opacity lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = L.map('map').setView([42.2, -71], 8), | |
mapQuestAttr = 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> — ', | |
osmDataAttr = 'Map data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', | |
mopt = { | |
url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.jpeg', | |
options: {attribution:mapQuestAttr + osmDataAttr, subdomains:'1234'} | |
}; | |
var mq=L.tileLayer(mopt.url,mopt.options).addTo(m); | |
var roads = L.geoJson.ajax("roads.json",{style:{opacity:0,fillOpacity:0}}).addTo(m); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<meta name="viewport" content="width=1024, user-scalable=no"> | |
<style> | |
html { height: 100% } | |
body { height: 100%; margin: 0; padding: 0;} | |
#map{ height: 100% } | |
</style> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.css" /> | |
<!--[if lte IE 8]> | |
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.ie.css" /> | |
<![endif]--> | |
<script src="http://cdn.leafletjs.com/leaflet-0.4.5/leaflet.js"></script> | |
<script src="leaflet.ajax.js"></script> | |
<title>Road Inventory</title> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script type="text/javascript" src="ascript.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L.GeoJSON.AJAX=L.GeoJSON.extend({ | |
defaultAJAXparams:{ | |
dataType:"json", | |
callbackParam:"callback" | |
}, | |
initialize: function (url, options) { // (String, Object) | |
this._url = url; | |
var ajaxParams = L.Util.extend({}, this.defaultAJAXparams); | |
for (var i in options) { | |
if (this.defaultAJAXparams.hasOwnProperty(i)) { | |
ajaxParams[i] = options[i]; | |
} | |
} | |
this.ajaxParams = ajaxParams; | |
this._layers = {}; | |
L.Util.setOptions(this, options); | |
if(this._url){ | |
this.addUrl(this._url); | |
} | |
}, | |
addUrl: function (url) { | |
var _this = this; | |
_this._url = url; | |
if(this.ajaxParams.dataType.toLowerCase()==="json"){ | |
L.Util.ajax(url, function(data){_this.addData(data);}); | |
}else if(this.ajaxParams.dataType.toLowerCase()==="jsonp"){ | |
L.Util.jsonp(url, function(data){_this.addData(data);}, _this.ajaxParams.callbackParam); | |
} | |
}, | |
refresh: function (url){ | |
url = url || this._url; | |
this.clearLayers(); | |
this.addUrl(url); | |
} | |
}); | |
L.Util.ajax = function (url, cb){ | |
var response, request = new XMLHttpRequest(); | |
request.open("GET",url); | |
request.onreadystatechange = function(){ | |
if (request.readyState === 4 && request.status === 200 ){ | |
response = JSON.parse(request.responseText); | |
cb(response); | |
} | |
}; | |
request.send(); | |
}; | |
L.Util.jsonp = function (url, cb, cbParam, callbackName){ | |
var cbn,ourl,cbs; | |
var cbParam = cbParam || "callback"; | |
if(callbackName){ | |
cbn= callbackName; | |
}else{ | |
cbs = "_" + Math.floor(Math.random()*1000000); | |
cbn = "L.Util.jsonp.cb." + cbs; | |
} | |
L.Util.jsonp.cb[cbs] = cb; | |
var scriptNode = L.DomUtil.create('script','', document.getElementsByTagName('body')[0] ); | |
scriptNode.type = 'text/javascript'; | |
if (url.indexOf("?") === -1 ){ | |
ourl = url+"?"+cbParam+"="+cbn; | |
}else{ | |
ourl = url+"&"+cbParam+"=."+cbn; | |
} | |
scriptNode.src = ourl; | |
}; | |
L.Util.jsonp.cb = {}; | |
L.geoJson.ajax = function (geojson, options) { | |
return new L.GeoJSON.AJAX(geojson, options); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment