package com.yc.sdk.gaodemap.api; import com.yc.entity.AttachmentConfig; import com.yc.sdk.gaodemap.action.GdMapServiceInit; import com.yc.sdk.gaodemap.entity.RegeoCodeEntity; import com.yc.sdk.map.entity.LocationEntity; import com.yc.sdk.map.service.AbstractMapService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service public class GaoDeMapService implements AbstractMapService { @Autowired GdMapService gdMapService; private static String KEY = AttachmentConfig.get("GaoDeWebServiceKey"); public GaoDeMapService() { this.gdMapService = GdMapServiceInit.getGdMapService(KEY); } @Override public LocationEntity getIPLocation(String ip) throws Exception { return null; } @Override public LocationEntity reverseGeocode(String longitude, String latitude, String ip) throws Exception { RegeoCodeEntity regeoV2 = gdMapService.getRegeoV2(longitude, latitude, ip); LocationEntity location = new LocationEntity(); location.setCountryName(regeoV2.getCountry()); location.setProvinceName(regeoV2.getProvince()); location.setCityName(regeoV2.getCity()); location.setSubLocality(regeoV2.getDistrict()); location.setThoroughfare(regeoV2.getTownship()); return location; } }