Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ static OverlayImage toOverlayImage(Object o) {
return OverlayImage.fromAsset(key);
}

static OverlayImage toOverlayImageFromFile(Object o) {
String imagePath = (String) o;
return OverlayImage.fromPath(imagePath);
}

static List<LatLng> toCoords(Object o) {
final List<?> data = (List) o;
final List<LatLng> points = new ArrayList<>(data.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ void interpret(HashMap<String, Object> json) {
final Object icon = json.get("icon");
if (icon != null) marker.setIcon(Convert.toOverlayImage(icon));

final Object iconFromFile = json.get("iconFromFile");
if (icon != null) marker.setIcon(Convert.toOverlayImageFromFile(iconFromFile));

final Object infoWindow = json.get("infoWindow");
if (infoWindow != null) this.infoWindowText = (String)infoWindow;
else this.infoWindowText = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ void interpret(HashMap<String, Object> option){
final Object patternImage = option.get("patternImage");
if (patternImage != null) path.setPatternImage(Convert.toOverlayImage(patternImage));

final Object patternImageFromFile = option.get("patternImageFromFile");
if (patternImageFromFile != null) path.setPatternImage(Convert.toOverlayImageFromFile(patternImageFromFile));

final Object patternInterval = option.get("patternInterval");
if (patternInterval != null) path.setPatternInterval(Math.round(((int) patternInterval)*density));

Expand Down
3 changes: 2 additions & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:naver_map_plugin_example/main.dart';
import '../lib/main.dart';


void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
Expand Down
7 changes: 7 additions & 0 deletions ios/Classes/src/JsonConversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ public func toOverlayImage(assetName: String, registrar: FlutterPluginRegistrar)
return NMFOverlayImage(name: assetPath)
}

public func toOverlayImageFromFile(imagePath: String) -> NMFOverlayImage? {
if let image = UIImage.init(contentsOfFile: imagePath) {
return NMFOverlayImage(image: image, reuseIdentifier: imagePath)
}
return nil
}

// ============================= 객체를 json 으로 =================================


Expand Down
4 changes: 4 additions & 0 deletions ios/Classes/src/NaverMarkersController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class NMarkerController: NSObject {
let overlayImage = toOverlayImage(assetName:assetName, registrar: registrar) {
marker.iconImage = overlayImage
}
if let imagePath = json["iconFromFile"] as? String,
let overlayImage = toOverlayImageFromFile(imagePath: imagePath) {
marker.iconImage = overlayImage
}
if let infoWindowText = json["infoWindow"] as? String {
self.infoWindowTitle = infoWindowText
}
Expand Down
4 changes: 4 additions & 0 deletions ios/Classes/src/NaverPathsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class NPathController: NSObject {
if let patternImage = json["patternImage"] as? String {
path.patternIcon = toOverlayImage(assetName: patternImage, registrar: registrar)
}
if let patternImageFromFile = json["patternImageFromCache"] as? String {
path.patternIcon = toOverlayImageFromFile(imagePath: patternImageFromFile)
}

if let patternInterval = json["patternInterval"] as? UInt {
path.patternInterval = patternInterval
}
Expand Down
1 change: 1 addition & 0 deletions lib/src/marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class Marker {
addIfPresent('subCaptionHaloColor', subCaptionHaloColor?.value);
addIfPresent('subCaptionRequestedWidth', subCaptionRequestedWidth);
addIfPresent('icon', icon?.assetName);
addIfPresent('iconFromCache', icon?.imageFilePath);
addIfPresent('infoWindow', infoWindow);
addIfPresent('anchor', anchor?._json);

Expand Down
17 changes: 12 additions & 5 deletions lib/src/overlay_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ part of naver_map_plugin;

/// 마커에 쓰일 비트맵 이미지를 정의한다.
class OverlayImage {
final AssetImage image;
final AssetBundleImageKey key;
final AssetImage? _image;
final AssetBundleImageKey? _key;
final String? _imagePath;

get assetName => Platform.isIOS ? image.assetName : key.name;
get assetName => Platform.isIOS ? _image?.assetName : _key?.name;

const OverlayImage._(this.image, this.key);
get imageFilePath => _imagePath;

const OverlayImage._({image, key, imagePath}) : _image = image, _key = key, _imagePath = imagePath;

/// ## [assetName] 이미지 중 [configuration]에 맞는 이미지를 찾아 [OverlayImage]객체를 만든다.
///
Expand Down Expand Up @@ -40,6 +43,10 @@ class OverlayImage {
final AssetImage assetImage = AssetImage(assetName);
final AssetBundleImageKey key = await assetImage.obtainKey(_configuration);

return OverlayImage._(assetImage, key);
return OverlayImage._(image: assetImage, key: key);
}

static OverlayImage fromImageFile(String imagePath) {
return OverlayImage._(imagePath: imagePath);
}
}
1 change: 1 addition & 0 deletions lib/src/path_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class PathOverlay {
'passedColor': passedColor.value,
'passedOutlineColor': passedOutlineColor.value,
'patternImage': patternImage?.assetName,
'patternImageFromCache' : patternImage?.imageFilePath,
'patternInterval': patternInterval,
'progress': progress,
'width': width,
Expand Down