COHEN Ariane (RIC-US)
2010-Oct-28 22:46 UTC
[Mapstraction] Mapstraction Digest, Vol 36, Issue 14
RRRrprrrrrrrrrrrrRrRr ----- Original Message ----- From: mapstraction-bounces at lists.mapstraction.com <mapstraction-bounces at lists.mapstraction.com> To: mapstraction at lists.mapstraction.com <mapstraction at lists.mapstraction.com> Sent: Thu Oct 28 15:06:07 2010 Subject: Mapstraction Digest, Vol 36, Issue 14 Send Mapstraction mailing list submissions to mapstraction at lists.mapstraction.com To subscribe or unsubscribe via the World Wide Web, visit http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com or, via email, send a message with subject or body ''help'' to mapstraction-request at lists.mapstraction.com You can reach the person managing the list at mapstraction-owner at lists.mapstraction.com When replying, please edit your Subject line so it is more specific than "Re: Contents of Mapstraction digest..." Today''s Topics: 1. Re: addJSON marker image (Andrew Turner) ---------------------------------------------------------------------- Message: 1 Date: Thu, 28 Oct 2010 13:44:11 -0400 From: Andrew Turner <ajturner at gmail.com> To: "mapstraction at lists.mapstraction.com" <mapstraction at lists.mapstraction.com> Cc: "mapstraction at lists.mapstraction.com" <mapstraction at lists.mapstraction.com> Subject: Re: [Mapstraction] addJSON marker image Message-ID: <3AE8C78B-4018-4B07-B39D-B79682F4BD5D at gmail.com> Content-Type: text/plain; charset="utf-8"; Format="flowed"; DelSp="yes" The addJSON was driven by integration of Mapstaction into Mapufacture a few years ago. I think standardizing is good and could follow the GeoJSON spec and properties attribute as used by projects like PolyMaps or come out of GeoCommons. Andrew (via mobile) On Oct 28, 2010, at 7:48 AM, Derek Fowler <dezfowler at gmail.com> wrote:> I''d be in favour of replacing the existing addJSON function with > this one. > > Does anyone actually use the current addJSON function? The > properties it requires you to have on your JSON seem quite arbitrary. > > Derek > > On 27 September 2010 14:40, Namith jo <joram5911 at hotmail.com> wrote: > there is a patch out there with addGeoJSON() originaly submited by > Callum Macdonald last year which I have added to. I somehow has not > been applied > > /** > * addGeoJSON is done processing > * @name mxn.Mapstraction#jsonDone > * @event > */ > ''jsonDone'', > > /** > * Adds geoJSON data to the map > * > * Data should conform to the GeoJSON spec. The relevant WithData > function will > * be called with the item.properties object. Set any relevant > properties there. > * For example: > * { "type": "FeatureCollection", > * "features": [ > * { "type": "Feature", > * "geometry": {"type": "Point", "coordinates": [102.0, 0.5]}, > * "properties": {"prop0": "value0", "icon": "http:// > icon.url/", "infoBubble": "Contents of bubble"} > * } > * } > * } > * > * @param {json} GeoJSON formatted JSON object. > */ > Mapstraction.prototype.addGeoJSON = function(json) { > var features; > if (typeof (json) == "string") { > features = eval(''('' + json + '')''); > } else { > features = json; > } > features = features.features; > var map = this.maps[this.api]; > var item; > var polyline; > var marker; > > if (features.type == "FeatureCollection") { > this.addGeoJSON(features.features); > } > > for (var i = 0; i < features.length; i++) { > item = features[i]; > switch (item.geometry.type) { > case "Point": > marker = new Marker(new LatLonPoint > (item.geometry.coordinates[0], item.geometry.coordinates[1])); > this.addMarkerWithData(marker, item.properties); > break; > > case "Polygon": > // Create an array of LatLongPoint objects from > the coordinates > var points = []; > for (var pi = 0; pi < item.geometry.coordinates > [0].length; pi++) { > points[pi] = new LatLonPoint > (item.geometry.coordinates[0][pi][0], item.geometry.coordinates[0] > [pi][1]) > } > polyline = new Polyline(points); > this.addPolylineWithData(polyline, > item.properties); > break; > > case "MultiPolygon": > // Create an array of LatLongPoint objects from > the coordinates > var points = []; > for (var oi = 0; oi < > item.geometry.coordinates.length; oi++) { > > for (var pi = 0; pi < > item.geometry.coordinates[oi].length; pi++) { > points[pi] = new LatLonPoint > (item.geometry.coordinates[oi][pi][0], item.geometry.coordinates[oi] > [pi][1]) > } > > polyline = new Polyline(points); > this.addPolylineWithData(polyline, > item.properties); > } > break; > > case "LineString": > // Create an array of LatLongPoint objects from > the coordinates > var points = []; > for (var pi = 0; pi < item.geometry.coordinates > [0].length; pi++) { > points[pi] = new LatLonPoint > (item.geometry.coordinates[0][pi][0], item.geometry.coordinates[0] > [pi][1]) > } > polyline = new Polyline(points); > // A LineString is an unclosed polyline in > mapstraction > item.properties.closed = false; > this.addPolylineWithData(polyline, > item.properties); > break; > > case "MultiLineString": > // Create an array of LatLongPoint objects from > the coordinates > var points = []; > for (var oi = 0; oi < > item.geometry.coordinates.length; oi++) { > > for (var pi = 0; pi < > item.geometry.coordinates[oi].length; pi++) { > points[pi] = new LatLonPoint > (item.geometry.coordinates[oi][pi][0], item.geometry.coordinates[oi] > [pi][1]) > } > > polyline = new Polyline(points); > this.addPolylineWithData(polyline, > item.properties); > } > break; > > default: > } > } > > this.jsonDone.fire({ > ''jsonDone'': this > }); > }; > > > Date: Sun, 26 Sep 2010 15:43:50 +0200 > > From: brunobergot at gmail.com > > To: mapstraction at lists.mapstraction.com > > Subject: Re: [Mapstraction] addJSON marker image > > > > > Hi again, > > > > Maybe we could use a property of each geojson item to get the icon > url ? > > > > I''ve tested something like that in mxn.core.js line 987 : > > > > icon : item.icon, > > > > When i use googlev3, openlayers, cloudmade or yahoo without define > the > > icon property of geojson items it gracefully fallback to the default > > icon of the API. And if i define the icon property in geojson i > can use > > a personnal icon for the markers created by addJSON function. > > > > {"type": "Feature", > > "geometry": {"type": "Point", "coordinates": [-4.7692, 48.3387]}, > > "icon_size": [20, 34], > > "icon": "plugins/gis2/images/marker.png"}, > > > > What do you think about it ? > > > > b_b > > > > Le 25/09/2010 18:28, bruno bergot a ?crit : > > > Hi, > > > > > > It''s my first post on this list. I''m develloping a plugin for > SPIP CMS > > > which use mapstraction API. > > > > > > I''ve noticed a problem in addJSON function : > > > > > > http://github.com/mapstraction/mxn/blob/master/source/mxn.core.js#L987 > > > > > > The image used by this function doesn''exist anymore, could we > change this ? > > > > > > I''ve found a ticket on a similar problem on openlayers trac : > > > > > > http://trac.openlayers.org/ticket/2273 > > > > > > Corrected by this commit : > > > > > > http://trac.openlayers.org/changeset/10698 > > > > > > Maybe we could use the same image in addJSON function ? > > > > > > http://www.openlayers.org/dev/img/marker.png > > > > > > Thanks > > > > > > ps : sorry for my poor english. > > > > > > b_b > > _______________________________________________ > > Mapstraction mailing list > > Mapstraction at lists.mapstraction.com > > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com > > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com > > > > > -- > Derek Fowler > m. +44 (0) 7966 512 369 > e. dezfowler at gmail.com > _______________________________________________ > Mapstraction mailing list > Mapstraction at lists.mapstraction.com > http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.mapstraction.com/pipermail/mapstraction-mapstraction.com/attachments/20101028/6d9b2d87/attachment.html> ------------------------------ _______________________________________________ Mapstraction mailing list Mapstraction at lists.mapstraction.com http://lists.mapstraction.com/listinfo.cgi/mapstraction-mapstraction.com End of Mapstraction Digest, Vol 36, Issue 14 ********************************************