简体   繁体   English

Mapstraction和JSON Google地图样式

[英]Mapstraction and JSON Google map style

I am using mapstraction v2. 我正在使用mapstraction v2。 When selecting Google as a provider, I need to stylize a google map v3. 选择Google作为提供商时,我需要对Google Map v3进行样式化。 I have used google's nice 'styled maps wizard' tool that produces the JSON object to pass to the style property of the google.maps.MapOptions object. 我已经使用了google不错的“样式化地图向导”工具,该工具会生成JSON对象以传递给google.maps.MapOptions对象的style属性。 The tool produces JSON that looks like something this { "featureType": "landscape.man_made", "elementType": "geometry.fill", "stylers": [ { "visibility": "on" }, { "color": "#404040" } ] }, etc... 该工具会生成类似于以下内容的JSON {“” featureType“:” landscape.man_made“,” elementType“:” geometry.fill“,” stylers“:[{” visibility“:” on“},{” color“: “#404040”}]}等...

However, I cannot figure out if / how to re-format this json object so that mapstraction can load it like this: 但是,我不知道是否/如何重新格式化此json对象,以便mapstraction可以像这样加载它:

    mapstraction = new mxn.Mapstraction('mymap', 'googlev3', true);
    json = { "featureType": "landscape.man_made", "elementType": "geometry.fill", "stylers": [ { "visibility": "on" },{ "color": "#404040" } ] }
    mapstraction.addJSON(json);

Even better, I would really like to know if I can use mxn.util.loadScript to fetch the json data directly from a url. 更好的是,我真的很想知道是否可以使用mxn.util.loadScript直接从url获取json数据。

Since I am totally new to web mapping, I may be trying to do something with mapstraction that is just not possible right now. 由于我是Web映射的新手,因此我可能正在尝试使用mapstraction进行某些操作,而现在这是不可能的。 Do you think so? 你这样认为吗? I searched through the archives and I noticed that the json looks different but I cannot find an answer that explains how to re-format it to make it usable by mapstraction. 我搜索了档案,发现json看起来有所不同,但找不到答案来说明如何重新格式化它以使其可通过mapstraction使用。 Do you know how to do this? 你知道怎么做吗?

Does this example help? 这个例子有帮助吗?

Extract from http://mapstraction.appspot.com/#json http://mapstraction.appspot.com/#json中提取

json = {
    features: [{
        "type": "Feature",
        "toponym": null,
        "title": "DSC_0023.JPG",
        "author": "ugef",
        "id": 1930723,
        "description": "",
        "categories": "california unitedstates sanjose eyefi",
        "geometry": {
            "type": "Point",
            "coordinates": [-121.896263,37.328655]
        },
        "properties": 
        {
            "icon_shadow": "http://mapstraction.appspot.com/images/blank.png",
            "icon_shadow_size": [0,0],
            "line_color": "",
            "icon": "http://mapstraction.appspot.com/images/flickr_marker.png",
            "line_opacity": 1.0,
            "pubdate": "2008/07/03 20:14:01 +0000",
            "line_width": 1.0,
            "poly_color": "",
            "icon_size": [16,16]
        },
        "source_id": 1000014
    }
    ]
}
// 
mapstraction.addJSON(json);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM