Closed gka closed 11 years ago
I think the best overall approach is to support direct string input. This allows users to get their SVG from a different domain however they want.
Yep, nice idea. Will add the following API:
map.setMap(svgString, opts);
fixed via 33da52ccff9f756bac76d4edf3bde782eb1954c3
Awesome! Thanks.
In some situations it is not possible to put the svg map files on the same origin on which the map is embedded. By default, xhr loading of resources from other domains is not possible, which is why the w3c introduced the CORS protocol.
Kartograph.js should be able to load maps from CORS enabled origins. jQuery already supports CORS.
I think there are different ways of handling this problem.
(1) Completely ignore the problem of loading svg assets and add a
map.setMap( svgAsDomOrString )
interface. This way, users are forced to find a proper way of getting to their svgs. Of course, this complicates the setup significantly for some users.(2) Try to wrap the CORS logic of jquery:
(3) Of course, we can also allow both (1) and (2).
(4) Idea for situations where CORS is no option at all (say for IE7): Since SVG is a simple plain/text resource it could easily be loaded through a JSONP api. Kartograph would for instance expect that the result of the request is a single string representing the svg file.